You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Alternatively, the script can use ``slip.onUndo`` to register a callback to run
204
+
during undo. Multiple callback can be registered and will be called in the right
205
+
order (that is, the reverse order in which they were registered).
206
+
207
+
.. code-block:: markdown
208
+
209
+
{exec-at-unpause pause}
210
+
```slip-script
211
+
let set_class = (elem, name, value) => {
212
+
let old_value = elem.style[name];
213
+
elem.style[name] = value;
214
+
slip.onUndo(() => {elem.style[name] = old_value})
215
+
}
216
+
let elem = document.querySelector("#id");
217
+
set_class(elem, "backgroundColor", "yellow");
218
+
set_class(elem, "color", "red");
219
+
```
220
+
221
+
222
+
Some functions accessible in the ``slip`` object already register their own callback. This is the case for ``slip.set_class(elem, className, bool)`` and ``slip.set_style(elem, styleName, styleValue)``.
223
+
224
+
Scripts have access to the ``slip.state`` object, which will be persisted from
0 commit comments