Which of the following will result in an invalid CSS transform value when used as use:scale={...}?
medium
A. use:scale={2}
B. use:scale={'2'}
C. use:scale={{ factor: 2 }}
D. use:scale={0.5}
Solution
Step 1: Analyze expected parameter type
The action expects a single number parameter factor, not an object.
Step 2: Identify which option passes an object instead of a number
use:scale={{ factor: 2 }} passes an object { factor: 2 }, which will cause scale(${newFactor}) to become scale([object Object]), an invalid CSS transform value.
Final Answer:
use:scale={{ factor: 2 }} -> Option C
Quick Check:
Passing object instead of number causes invalid transform = C [OK]
Hint: Match parameter type expected by action exactly [OK]
Common Mistakes:
Passing object when number expected
Passing string instead of number (allowed but may cause visual issues)
Passing objects when primitive expected
5. You want to create a Svelte action tooltip that shows a message passed as a parameter and updates the message if it changes. Which of these implementations correctly handles parameter updates?
hard
A.
function tooltip(node, message) {
const tip = document.createElement('div');
tip.textContent = message;
node.appendChild(tip);
}
B.
function tooltip(node, message) {
node.title = message;
return {};
}
C.
function tooltip(node, message) {
node.setAttribute('tooltip', message);
}