Skip to content

Commit

Permalink
refactor DOM methods to correct base class implementation (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
thescientist13 authored Jan 11, 2024
1 parent 0bb1fa8 commit ba8baf0
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/dom-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ class Element extends Node {
this.attributes = {};
}

attachShadow(options) {
this.shadowRoot = new ShadowRoot(options);

return this.shadowRoot;
}

// https://github.com/mfreed7/declarative-shadow-dom/blob/master/README.md#serialization
// eslint-disable-next-line
getInnerHTML() {
return this.shadowRoot ? this.shadowRoot.innerHTML : this.innerHTML;
}

setAttribute(name, value) {
this.attributes[name] = value;
}
Expand Down Expand Up @@ -68,19 +80,7 @@ class Document extends Node {
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement
// EventTarget <- Node <- Element <- HTMLElement
class HTMLElement extends Element {
attachShadow(options) {
this.shadowRoot = new ShadowRoot(options);

return this.shadowRoot;
}

connectedCallback() { }

// https://github.com/mfreed7/declarative-shadow-dom/blob/master/README.md#serialization
// eslint-disable-next-line
getInnerHTML(options = {}) {
return this.shadowRoot.innerHTML;
}
}

// https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment
Expand Down

0 comments on commit ba8baf0

Please sign in to comment.