diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2022-11-27 09:40:47 +0000 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2022-11-27 09:40:47 +0000 |
commit | 7bcd4fd2465631f4a17e1920594e9c2536b6f057 (patch) | |
tree | 5c12885af1c2a2f852ef21493c001a57b7f133cb /test | |
parent | 764fca4f3abfc7437003f496d52039ad7e6b779d (diff) | |
download | netsurf-7bcd4fd2465631f4a17e1920594e9c2536b6f057.tar.gz |
DOMTokenList: Add support and testing for this
We add both DOMTokenList and DOMSettableTokenList and introduce
polyfills for stringifying it until nsgenbind can do that.
We also bring in a test to demonstrate all that we have.
Note: This does not implement the extra methods that exist according
to MDN, we may need a polyfill to bring that up to snuff.
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/js/class-list.html | 29 | ||||
-rw-r--r-- | test/js/index.html | 1 |
2 files changed, 30 insertions, 0 deletions
diff --git a/test/js/class-list.html b/test/js/class-list.html new file mode 100644 index 000000000..4c73283e5 --- /dev/null +++ b/test/js/class-list.html @@ -0,0 +1,29 @@ +<html> + <head> + <title>Class List (and other token lists?)</title> + <style> + .bad { background-color: red; } + .ok { background-color: green; } + </style> + </head> + <body> + <h1>This is a set of demonstrators for the token list Element.classList</h1> + <h2>This first is taken from the MDN for DOMTokenList</h2> + <span id="demo1" class=" d d e f bad"></span> + <script> + var span = document.getElementById("demo1"); + var classes = span.classList; + classes.add("x", "d", "g"); + classes.remove("e", "g"); + classes.toggle("d"); // Toggles d off + classes.toggle("q", false); // Forces q off (won't be present) + classes.toggle("d"); // Toggles d on + classes.toggle("d", true); // Forces d on (won't toggle it off again) + if (classes.contains("d")) { + classes.add("ok") + classes.remove("bad") + span.textContent = "span classList is \"" + classes + '"'; + } + </script> + </body> +</html> diff --git a/test/js/index.html b/test/js/index.html index 032946726..6d2c6541e 100644 --- a/test/js/index.html +++ b/test/js/index.html @@ -104,6 +104,7 @@ <li><a href="assorted-log-doc-write.html">console.log and document.write</a></li> <li><a href="wikipedia-lcm.html">Example from wikipedia</a></li> <li><a href="verify-instanceofness.html">Check instanceof behaviour</a></li> +<li><a href="class-list.html">Class list (and other token lists?)</a></li> <li><a href="mandelbrot.html">Canvas/ImageData Mandelbrot ploter</a></li> <li><a href="life.html">Game of Life</a></li> </ul> |