scala-js-dom
scala-js-dom copied to clipboard
Support for Shadow DOM
Hello, it would be great if Scala JS would also have a Shadow DOM implementation, i.e. provide a way to access Shadow DOM's.
Currently the Spec is in Draft: https://w3c.github.io/webcomponents/spec/shadow/#widl-Element-attachShadow-ShadowRoot-ShadowRootInit-shadowRootInitDict
However there are already really great polyfills here: http://webcomponents.org/polyfills/shadow-dom/
Definitely a sound addition!
If anyone wants to contribute this a few thoughts:
- It should probably live in
org.scalajs.dom.experimental.shadowdom
- There would be a package object for
shadowdom
defining implicit coercions fromElement
onto a trait exposingshadowRoot
,attachShadow
etc. members. - Since the API is experimental and likely to change in future, a comment at the top of the file linking the version of the specification implemented and a note with it's release date (currently 15th December) will aid tracking support longer term.
ShadowDOM has a dependency on https://www.w3.org/TR/cssom-view/, which we currently do not implement.
Now, core parts of the ShadowDOM are in the DOM Standard. https://github.com/WICG/webcomponents/issues/661
Also now can we have this as a non-experimental API? https://caniuse.com/shadowdomv1
@unarist if you're up for it will consider a PR! :)