pseudo-dom 0.9.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +918 -18
- package/browser/pseudo-dom.js +3296 -604
- package/browser/pseudo-dom.min.js +1 -1
- package/dist/factories/createDataset.d.ts +10 -10
- package/dist/factories/createDataset.js +78 -78
- package/dist/factories/createStyleDeclaration.d.ts +30 -30
- package/dist/factories/createStyleDeclaration.js +64 -64
- package/dist/factories/parseHTML.d.ts +13 -0
- package/dist/factories/parseHTML.js +84 -0
- package/dist/factories/parseHTML.min.js +1 -0
- package/dist/factories/serializeHTML.d.ts +15 -0
- package/dist/factories/serializeHTML.js +114 -0
- package/dist/factories/serializeHTML.min.js +1 -0
- package/dist/interfaces/PseudoCSSStyleDeclaration.d.ts +14 -14
- package/dist/interfaces/PseudoCSSStyleDeclaration.js +5 -5
- package/dist/interfaces/PseudoElement.d.ts +765 -702
- package/dist/interfaces/PseudoHTMLElement.d.ts +33 -33
- package/dist/interfaces/PseudoShadowRoot.d.ts +9 -0
- package/dist/services/CSSStyleDeclarationService.d.ts +73 -73
- package/dist/services/CSSStyleDeclarationService.js +156 -156
- package/dist/services/ElementService.d.ts +371 -191
- package/dist/services/ElementService.js +732 -426
- package/dist/services/ElementService.min.js +1 -1
- package/dist/services/HTMLElementService.d.ts +32 -0
- package/dist/services/HTMLElementService.js +67 -0
- package/dist/services/HTMLElementService.min.js +1 -1
- package/dist/services/NodeService.d.ts +8 -0
- package/dist/services/NodeService.js +11 -0
- package/dist/services/NodeService.min.js +1 -1
- package/dist/services/ShadowRootService.d.ts +12 -0
- package/dist/services/ShadowRootService.js +16 -1
- package/dist/services/ShadowRootService.min.js +1 -1
- package/package.json +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";require("core-js/modules/esnext.iterator.constructor.js"),require("core-js/modules/esnext.iterator.every.js"),require("core-js/modules/esnext.iterator.find.js"),require("core-js/modules/esnext.iterator.for-each.js"),require("core-js/modules/esnext.iterator.map.js"),require("core-js/modules/esnext.iterator.some.js");var __importDefault=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.ElementService=void 0;const createEvent_1=__importDefault(require("../factories/createEvent")),NodeService_1=require("./NodeService"),AttrService_1=require("./AttrService"),DOMTokenListService_1=require("./DOMTokenListService"),NamedNodeMapService_1=require("./NamedNodeMapService"),getParentNodesFromAttribute_1=__importDefault(require("../functions/getParentNodesFromAttribute")),HTMLCollectionService_1=require("./HTMLCollectionService"),cloneObject_1=__importDefault(require("si-funciona/dist/helpers/objects/cloneObject")),isEqual_1=__importDefault(require("si-funciona/dist/helpers/objects/isEqual")),query_1=require("../factories/query");class ElementService extends NodeService_1.NodeService{constructor({tagName:e="",attributes:t=[],parent:r=null,children:
|
|
1
|
+
"use strict";require("core-js/modules/esnext.iterator.constructor.js"),require("core-js/modules/esnext.iterator.every.js"),require("core-js/modules/esnext.iterator.find.js"),require("core-js/modules/esnext.iterator.for-each.js"),require("core-js/modules/esnext.iterator.map.js"),require("core-js/modules/esnext.iterator.some.js"),require("core-js/modules/esnext.set.add-all.js"),require("core-js/modules/esnext.set.delete-all.js"),require("core-js/modules/esnext.set.difference.js"),require("core-js/modules/esnext.set.every.js"),require("core-js/modules/esnext.set.filter.js"),require("core-js/modules/esnext.set.find.js"),require("core-js/modules/esnext.set.intersection.js"),require("core-js/modules/esnext.set.is-disjoint-from.js"),require("core-js/modules/esnext.set.is-subset-of.js"),require("core-js/modules/esnext.set.is-superset-of.js"),require("core-js/modules/esnext.set.join.js"),require("core-js/modules/esnext.set.map.js"),require("core-js/modules/esnext.set.reduce.js"),require("core-js/modules/esnext.set.some.js"),require("core-js/modules/esnext.set.symmetric-difference.js"),require("core-js/modules/esnext.set.union.js");var __importDefault=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.ElementService=void 0;const createEvent_1=__importDefault(require("../factories/createEvent")),NodeService_1=require("./NodeService"),AttrService_1=require("./AttrService"),DOMTokenListService_1=require("./DOMTokenListService"),NamedNodeMapService_1=require("./NamedNodeMapService"),getParentNodesFromAttribute_1=__importDefault(require("../functions/getParentNodesFromAttribute")),HTMLCollectionService_1=require("./HTMLCollectionService"),cloneObject_1=__importDefault(require("si-funciona/dist/helpers/objects/cloneObject")),isEqual_1=__importDefault(require("si-funciona/dist/helpers/objects/isEqual")),query_1=require("../factories/query"),ShadowRootService_1=require("./ShadowRootService"),serializeHTML_1=require("../factories/serializeHTML"),zeroRect=()=>({x:0,y:0,width:0,height:0,top:0,right:0,bottom:0,left:0});class ElementService extends NodeService_1.NodeService{constructor({tagName:e="",attributes:t=[],parent:r=null,children:s=[]}={}){super(),this.boundingClientRect=zeroRect(),this.clientRects=[],this.animations=[],this.isVisible=!0,this.capturedPointers=new Set,this.shadowRootInstance=null,this.defaultEventApplied=!1,this.tokenList=new DOMTokenListService_1.DOMTokenListService,this.tag=e,this.attributeList=t.concat([{name:"className",value:""},{name:"id",value:""},{name:"clientHeight",value:0},{name:"clientLeft",value:0},{name:"clientTop",value:0},{name:"clientWidth",value:0},{name:"scrollHeight",value:0},{name:"scrollLeft",value:0},{name:"scrollTop",value:0},{name:"scrollWidth",value:0}]),this.propertyAttributes=this.attributeList.map(({name:e})=>e),this.attributeList.forEach(({name:e,value:t})=>{this[e]=t}),s.forEach(e=>{if(!e||"number"!=typeof e.nodeType)throw new TypeError("The children of an element must be nodes.");this.appendChild(e)}),r&&r.appendChild(this)}currentAttributes(){return this.attributeList.map(({name:e,value:t})=>({name:e,value:this.propertyAttributes.indexOf(e)>=0?this[e]:t}))}get nodeName(){return this.tag}cloneShallow(){const e=new this.constructor({tagName:this.tag});return e.attributeList.length=0,this.currentAttributes().forEach(({name:t,value:r})=>{const s="object"==typeof r&&null!==r?(0,cloneObject_1.default)(r):r;e.attributeList.push({name:t,value:s}),e.propertyAttributes.indexOf(t)>=0&&(e[t]=s)}),e.ownerDocumentStore=this.ownerDocumentStore,e}equalsShallow(e){const t=this.currentAttributes(),r=e.currentAttributes();return this.nodeName===e.nodeName&&t.length===r.length&&t.every(({name:e,value:t})=>{const s=r.find(t=>t.name===e);return void 0!==s&&(0,isEqual_1.default)(t,s.value)})}get tagName(){return this.tag}get localName(){return this.tag}get prefix(){return null}get innerHTML(){return(0,serializeHTML_1.serializeChildren)(this)}get outerHTML(){return(0,serializeHTML_1.serializeOuter)(this)}get nodeType(){return NodeService_1.NodeService.ELEMENT_NODE}get attributes(){return new NamedNodeMapService_1.NamedNodeMapService(this.currentAttributes().map(({name:e,value:t})=>new AttrService_1.AttrService(e,String(t),this)))}get classList(){return this.tokenList}get className(){return this.tokenList.value}set className(e){this.tokenList.value=e}get children(){return new HTMLCollectionService_1.HTMLCollectionService(this)}get childElementCount(){return this.children.length}get firstElementChild(){return this.children.item(0)}get lastElementChild(){const e=this.children;return e.item(e.length-1)}get nextElementSibling(){let e=this.nextSibling;for(;e&&e.nodeType!==NodeService_1.NodeService.ELEMENT_NODE;)e=e.nextSibling;return e}get previousElementSibling(){let e=this.previousSibling;for(;e&&e.nodeType!==NodeService_1.NodeService.ELEMENT_NODE;)e=e.previousSibling;return e}insertAdjacentElement(e,t){return this.insertAdjacent(e,t)}insertAdjacentText(e,t){this.insertAdjacent(e,t)}insertAdjacent(e,t){switch(e){case"beforebegin":return this.parentNode?(this.before(t),t):null;case"afterbegin":return this.prepend(t),t;case"beforeend":return this.append(t),t;case"afterend":return this.parentNode?(this.after(t),t):null;default:throw new Error(`"${e}" is not one of beforebegin, afterbegin, beforeend or afterend.`)}}insertAdjacentHTML(e,t){throw new Error("ElementService.insertAdjacentHTML() is not implemented yet.")}matches(e){return(0,query_1.matches)(this,e)}closest(e){return(0,query_1.closest)(this,e)}applyDefaultEvent(){let e=e=>{};if(this.defaultEventApplied)return e;switch(this.tagName){case"button":case"input":e=e=>{const t=String(this.getAttribute("type")||this.type||"").toLowerCase(),r="button"===this.tagName?"button"!==t&&"reset"!==t:/^(submit|image)$/.test(t),s=(0,getParentNodesFromAttribute_1.default)("tagName","form",this);r&&s.length&&!this.hasAttribute("disabled")&&s[s.length-1].dispatchEvent((0,createEvent_1.default)("submit",{},{browser:!0,trusted:e.isTrusted}))},super.setDefaultEvent("click",e),this.defaultEventApplied=!0}return e}childInserted(e){"function"==typeof e.applyDefaultEvent&&e.applyDefaultEvent()}hasAttribute(e){return this.attributeList.some(({name:t})=>t===e)}setAttribute(e,t){const r=this.attributeList.find(({name:t})=>t===e);r?r.value=t:this.attributeList.push({name:e,value:t}),this.propertyAttributes.indexOf(e)>=0&&(this[e]=t)}getAttribute(e){const t=this.currentAttributes().find(({name:t})=>t===e);return t?t.value:null}removeAttribute(e){const t=this.attributeList.findIndex(({name:t})=>t===e);t>=0&&this.attributeList.splice(t,1)}getAttributeNames(){return this.currentAttributes().map(({name:e})=>e)}hasAttributes(){return this.attributeList.length>0}toggleAttribute(e,t){const r=this.hasAttribute(e),s="boolean"==typeof t?t:!r;return s&&!r?this.setAttribute(e,""):!s&&r&&this.removeAttribute(e),s}getBoundingClientRect(){return this.boundingClientRect}getClientRects(){return this.clientRects}getAnimations(){return this.animations}checkVisibility(){return this.isVisible}computedStyleMap(){const e=this.style;return{get:t=>{const r=e?e.getPropertyValue(t):"";return""===r?void 0:r}}}hasPointerCapture(e){return this.capturedPointers.has(e)}setPointerCapture(e){this.capturedPointers.add(e)}releasePointerCapture(e){this.capturedPointers.delete(e)}scroll(e=0,t=0){if("number"==typeof e)return this.scrollLeft=e,void(this.scrollTop=t);"number"==typeof e.left&&(this.scrollLeft=e.left),"number"==typeof e.top&&(this.scrollTop=e.top)}scrollTo(e=0,t=0){this.scroll(e,t)}scrollBy(e=0,t=0){"number"!=typeof e?this.scroll({left:this.scrollLeft+(e.left||0),top:this.scrollTop+(e.top||0)}):this.scroll(this.scrollLeft+e,this.scrollTop+t)}scrollIntoView(){}requestFullscreen(){return Promise.resolve()}requestPointerLock(){return Promise.resolve()}attachShadow(e){if(this.shadowRootInstance)throw new Error("Shadow root cannot be created on a host which already hosts a shadow tree.");const t=new ShadowRootService_1.ShadowRootService;return t.host=this,t.mode=e.mode,this.shadowRootInstance=t,t}get shadowRoot(){return this.shadowRootInstance&&"open"===this.shadowRootInstance.mode?this.shadowRootInstance:null}}exports.ElementService=ElementService;
|
|
@@ -64,6 +64,38 @@ export declare class HTMLElementService extends ElementService implements Partia
|
|
|
64
64
|
* @returns {boolean}
|
|
65
65
|
*/
|
|
66
66
|
protected equalsShallow(other: NodeService): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Parses html with this class building each new element (matches HTML: parsed elements behave like plain
|
|
69
|
+
* HTMLElements, not whatever specialized class happens to be setting innerHTML / outerHTML).
|
|
70
|
+
* @param {string} html
|
|
71
|
+
* @returns {Array<*>}
|
|
72
|
+
*/
|
|
73
|
+
private parse;
|
|
74
|
+
/**
|
|
75
|
+
* Replace this element's children by parsing html. innerHTML's setter is here rather than on ElementService (which
|
|
76
|
+
* only has the getter) because building the new elements needs a concrete element class - see parse().
|
|
77
|
+
* @param {string} html
|
|
78
|
+
* @returns {undefined}
|
|
79
|
+
*/
|
|
80
|
+
set innerHTML(html: string);
|
|
81
|
+
get innerHTML(): string;
|
|
82
|
+
/**
|
|
83
|
+
* Replace this element itself, in its parent, by parsing html. Does nothing when it has no parent, like
|
|
84
|
+
* replaceWith. outerHTML's setter is here rather than on ElementService for the same reason as innerHTML's.
|
|
85
|
+
* @param {string} html
|
|
86
|
+
* @returns {undefined}
|
|
87
|
+
*/
|
|
88
|
+
set outerHTML(html: string);
|
|
89
|
+
get outerHTML(): string;
|
|
90
|
+
/**
|
|
91
|
+
* Parse html and insert the resulting nodes at the given position, like insertAdjacentElement /
|
|
92
|
+
* insertAdjacentText.
|
|
93
|
+
* @param {string} position beforebegin, afterbegin, beforeend or afterend
|
|
94
|
+
* @param {string} html The markup to parse
|
|
95
|
+
* @returns {undefined}
|
|
96
|
+
* @throws {Error} When the position is not one of the four above
|
|
97
|
+
*/
|
|
98
|
+
insertAdjacentHTML(position: string, html: string): void;
|
|
67
99
|
/**
|
|
68
100
|
* Whether this element can have the focus: form controls and links which are not disabled, and anything with a tabindex.
|
|
69
101
|
* @returns {boolean}
|
|
@@ -16,6 +16,7 @@ const createEvent_1 = __importDefault(require('../factories/createEvent'))
|
|
|
16
16
|
const activeElement_1 = require('../functions/activeElement')
|
|
17
17
|
const createStyleDeclaration_1 = __importDefault(require('../factories/createStyleDeclaration'))
|
|
18
18
|
const createDataset_1 = __importDefault(require('../factories/createDataset'))
|
|
19
|
+
const parseHTML_1 = __importDefault(require('../factories/parseHTML'))
|
|
19
20
|
/**
|
|
20
21
|
* Simulate the behaviour of the HTMLElement Class when there is no DOM available.
|
|
21
22
|
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
@@ -113,6 +114,72 @@ class HTMLElementService extends ElementService_1.ElementService {
|
|
|
113
114
|
return super.equalsShallow(other) && this.style.cssText === other.style.cssText
|
|
114
115
|
}
|
|
115
116
|
|
|
117
|
+
/**
|
|
118
|
+
* Parses html with this class building each new element (matches HTML: parsed elements behave like plain
|
|
119
|
+
* HTMLElements, not whatever specialized class happens to be setting innerHTML / outerHTML).
|
|
120
|
+
* @param {string} html
|
|
121
|
+
* @returns {Array<*>}
|
|
122
|
+
*/
|
|
123
|
+
parse (html) {
|
|
124
|
+
return (0, parseHTML_1.default)(html, this.ownerDocument, HTMLElementService)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Replace this element's children by parsing html. innerHTML's setter is here rather than on ElementService (which
|
|
129
|
+
* only has the getter) because building the new elements needs a concrete element class - see parse().
|
|
130
|
+
* @param {string} html
|
|
131
|
+
* @returns {undefined}
|
|
132
|
+
*/
|
|
133
|
+
set innerHTML (html) {
|
|
134
|
+
this.replaceChildren(...this.parse(html))
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
get innerHTML () {
|
|
138
|
+
return super.innerHTML
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Replace this element itself, in its parent, by parsing html. Does nothing when it has no parent, like
|
|
143
|
+
* replaceWith. outerHTML's setter is here rather than on ElementService for the same reason as innerHTML's.
|
|
144
|
+
* @param {string} html
|
|
145
|
+
* @returns {undefined}
|
|
146
|
+
*/
|
|
147
|
+
set outerHTML (html) {
|
|
148
|
+
this.replaceWith(...this.parse(html))
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
get outerHTML () {
|
|
152
|
+
return super.outerHTML
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Parse html and insert the resulting nodes at the given position, like insertAdjacentElement /
|
|
157
|
+
* insertAdjacentText.
|
|
158
|
+
* @param {string} position beforebegin, afterbegin, beforeend or afterend
|
|
159
|
+
* @param {string} html The markup to parse
|
|
160
|
+
* @returns {undefined}
|
|
161
|
+
* @throws {Error} When the position is not one of the four above
|
|
162
|
+
*/
|
|
163
|
+
insertAdjacentHTML (position, html) {
|
|
164
|
+
const nodes = this.parse(html)
|
|
165
|
+
switch (position) {
|
|
166
|
+
case 'beforebegin':
|
|
167
|
+
this.before(...nodes)
|
|
168
|
+
return
|
|
169
|
+
case 'afterbegin':
|
|
170
|
+
this.prepend(...nodes)
|
|
171
|
+
return
|
|
172
|
+
case 'beforeend':
|
|
173
|
+
this.append(...nodes)
|
|
174
|
+
return
|
|
175
|
+
case 'afterend':
|
|
176
|
+
this.after(...nodes)
|
|
177
|
+
return
|
|
178
|
+
default:
|
|
179
|
+
throw new Error(`insertAdjacentHTML: "${position}" is not one of beforebegin, afterbegin, beforeend, afterend.`)
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
116
183
|
/**
|
|
117
184
|
* Whether this element can have the focus: form controls and links which are not disabled, and anything with a tabindex.
|
|
118
185
|
* @returns {boolean}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __importDefault=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.HTMLElementService=void 0;const ElementService_1=require("./ElementService"),createEvent_1=__importDefault(require("../factories/createEvent")),activeElement_1=require("../functions/activeElement"),createStyleDeclaration_1=__importDefault(require("../factories/createStyleDeclaration")),createDataset_1=__importDefault(require("../factories/createDataset"));class HTMLElementService extends ElementService_1.ElementService{constructor({tagName:e="",parent:t=null,children:
|
|
1
|
+
"use strict";var __importDefault=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.HTMLElementService=void 0;const ElementService_1=require("./ElementService"),createEvent_1=__importDefault(require("../factories/createEvent")),activeElement_1=require("../functions/activeElement"),createStyleDeclaration_1=__importDefault(require("../factories/createStyleDeclaration")),createDataset_1=__importDefault(require("../factories/createDataset")),parseHTML_1=__importDefault(require("../factories/parseHTML"));class HTMLElementService extends ElementService_1.ElementService{constructor({tagName:e="",parent:t=null,children:r=[]}={}){super({tagName:e,attributes:[{name:"hidden",value:!1},{name:"offsetHeight",value:0},{name:"offsetLeft",value:0},{name:"offsetParent",value:null},{name:"offsetTop",value:0},{name:"offsetWidth",value:0},{name:"title",value:""}],parent:t,children:r}),this.styleDeclaration=(0,createStyleDeclaration_1.default)(),this.datasetProxy=(0,createDataset_1.default)(this)}get style(){return this.styleDeclaration}get dataset(){return this.datasetProxy}cloneShallow(){const e=super.cloneShallow();return e.style.cssText=this.style.cssText,e}equalsShallow(e){return super.equalsShallow(e)&&this.style.cssText===e.style.cssText}parse(e){return(0,parseHTML_1.default)(e,this.ownerDocument,HTMLElementService)}set innerHTML(e){this.replaceChildren(...this.parse(e))}get innerHTML(){return super.innerHTML}set outerHTML(e){this.replaceWith(...this.parse(e))}get outerHTML(){return super.outerHTML}insertAdjacentHTML(e,t){const r=this.parse(t);switch(e){case"beforebegin":return void this.before(...r);case"afterbegin":return void this.prepend(...r);case"beforeend":return void this.append(...r);case"afterend":return void this.after(...r);default:throw new Error(`insertAdjacentHTML: "${e}" is not one of beforebegin, afterbegin, beforeend, afterend.`)}}get canFocus(){if(this.hasAttribute("disabled"))return!1;switch(this.tagName){case"button":case"select":case"textarea":return!0;case"input":return"hidden"!==String(this.getAttribute("type")||"").toLowerCase();case"a":return this.hasAttribute("href")||this.hasAttribute("tabindex");default:return this.hasAttribute("tabindex")}}click(){this.hasAttribute("disabled")||this.dispatchEvent((0,createEvent_1.default)("click",{},{browser:!0}))}focus(){const e=this.getRootNode(),t=(0,activeElement_1.getActiveElement)(e);if(!this.canFocus||t===this)return;const r=(e,t,r)=>{e.dispatchEvent((0,createEvent_1.default)(t,{relatedTarget:r},{browser:!0,trusted:!0}))};t&&(r(t,"blur",this),r(t,"focusout",this)),(0,activeElement_1.setActiveElement)(e,this),r(this,"focus",t),r(this,"focusin",t)}blur(){const e=this.getRootNode();(0,activeElement_1.getActiveElement)(e)===this&&((0,activeElement_1.setActiveElement)(e,null),this.dispatchEvent((0,createEvent_1.default)("blur",{relatedTarget:null},{browser:!0,trusted:!0})),this.dispatchEvent((0,createEvent_1.default)("focusout",{relatedTarget:null},{browser:!0,trusted:!0})))}}exports.HTMLElementService=HTMLElementService;
|
|
@@ -152,6 +152,14 @@ export declare class NodeService extends EventTargetService implements PseudoNod
|
|
|
152
152
|
* @returns {PseudoHTMLCollection}
|
|
153
153
|
*/
|
|
154
154
|
getElementsByClassName(className: string): HTMLCollectionService;
|
|
155
|
+
/**
|
|
156
|
+
* Every element below this node with the given tag name, live. There is no real namespace parsing here, so this
|
|
157
|
+
* ignores the namespace and behaves exactly like getElementsByTagName.
|
|
158
|
+
* @param {string} namespace Ignored
|
|
159
|
+
* @param {string} tagName
|
|
160
|
+
* @returns {PseudoHTMLCollection}
|
|
161
|
+
*/
|
|
162
|
+
getElementsByTagNameNS(namespace: string, tagName: string): HTMLCollectionService;
|
|
155
163
|
/**
|
|
156
164
|
* The first element below this node which matches the CSS selector, in tree order, or null when there is none.
|
|
157
165
|
* @param {string} selectors A CSS selector
|
|
@@ -297,6 +297,17 @@ class NodeService extends EventTargetService_1.default {
|
|
|
297
297
|
return new HTMLCollectionService_1.HTMLCollectionService(this, element => names.every(name => element.classList.contains(name)), true)
|
|
298
298
|
}
|
|
299
299
|
|
|
300
|
+
/**
|
|
301
|
+
* Every element below this node with the given tag name, live. There is no real namespace parsing here, so this
|
|
302
|
+
* ignores the namespace and behaves exactly like getElementsByTagName.
|
|
303
|
+
* @param {string} namespace Ignored
|
|
304
|
+
* @param {string} tagName
|
|
305
|
+
* @returns {PseudoHTMLCollection}
|
|
306
|
+
*/
|
|
307
|
+
getElementsByTagNameNS (namespace, tagName) {
|
|
308
|
+
return this.getElementsByTagName(tagName)
|
|
309
|
+
}
|
|
310
|
+
|
|
300
311
|
/**
|
|
301
312
|
* The first element below this node which matches the CSS selector, in tree order, or null when there is none.
|
|
302
313
|
* @param {string} selectors A CSS selector
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";require("core-js/modules/esnext.iterator.constructor.js"),require("core-js/modules/esnext.iterator.every.js"),require("core-js/modules/esnext.iterator.filter.js"),require("core-js/modules/esnext.iterator.for-each.js");var __importDefault=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.CommentService=exports.TextService=exports.NodeService=void 0;const generateNodeList_1=__importDefault(require("../factories/generateNodeList")),TreeLinker_1=require("collect-your-stuff/dist/collections/linked-tree-list/TreeLinker"),EventTargetService_1=__importDefault(require("./EventTargetService")),HTMLCollectionService_1=require("./HTMLCollectionService"),query_1=require("../factories/query");class NodeService extends EventTargetService_1.default{constructor(){super(),this.nodeValueStore=null,this.ownerDocumentStore=null,this.nodeId=NodeService.nextNodeId++,this.nodeNameValue="",this.childList=(0,generateNodeList_1.default)(),this.parent=null,this.listLinker=null}get baseURI(){return window.location||"/"}get childNodes(){return this.childList}get firstChild(){return this.childList.first?this.childList.first.data:null}get isConnected(){return this.getRootNode().nodeType===NodeService.DOCUMENT_NODE}get lastChild(){return this.childList.last?this.childList.last.data:null}get nextSibling(){return this.listLinker&&this.listLinker.next?this.listLinker.next.data:null}get nodeName(){return this.nodeNameValue||""}get nodeType(){return NodeService.DEFAULT_NODE}get nodeValue(){return this.nodeValueStore}set nodeValue(e){this.nodeValueStore=e}get ownerDocument(){if(this.nodeType===NodeService.DOCUMENT_NODE)return null;const e=this.getRootNode();return e.nodeType===NodeService.DOCUMENT_NODE?e:this.ownerDocumentStore}get parentNode(){return this.parent}get parentElement(){return this.parent&&this.parent.nodeType===NodeService.ELEMENT_NODE?this.parent:null}get previousSibling(){return this.listLinker&&this.listLinker.prev?this.listLinker.prev.data:null}get textContent(){if(this.nodeType===NodeService.DOCUMENT_NODE||this.nodeType===NodeService.DOCUMENT_TYPE_NODE)return null;let e="";return Array.from(this.childNodes).forEach(t=>{t.nodeType===NodeService.TEXT_NODE?e+=t.nodeValue:t.nodeType!==NodeService.COMMENT_NODE&&(e+=t.textContent)}),e}set textContent(e){if(this.nodeType!==NodeService.DOCUMENT_NODE&&this.nodeType!==NodeService.DOCUMENT_TYPE_NODE){for(;this.firstChild;)this.removeChild(this.firstChild);if(null!=e&&""!==String(e)){const t=new TextService(String(e));t.ownerDocumentStore=this.ownerDocument,this.appendChild(t)}}}appendChild(e){return this.insertBefore(e,null)}get acceptsChildren(){return!0}cloneShallow(){const e=new this.constructor;return e.nodeValue=this.nodeValue,e.ownerDocumentStore=this.ownerDocumentStore,e}equalsShallow(e){return this.nodeName===e.nodeName&&this.nodeValue===e.nodeValue}append(...e){e.forEach(e=>this.appendChild(this.toChildNode(e)))}prepend(...e){const t=this.firstChild;e.forEach(e=>this.insertBefore(this.toChildNode(e),t))}replaceChildren(...e){for(;this.firstChild;)this.removeChild(this.firstChild);this.append(...e)}before(...e){const t=this.parentNode;t&&e.forEach(e=>t.insertBefore(this.toChildNode(e),this))}after(...e){const t=this.parentNode;if(!t)return;const r=this.nextSibling;e.forEach(e=>t.insertBefore(this.toChildNode(e),r))}replaceWith(...e){const t=this.parentNode;t&&(e.forEach(e=>t.insertBefore(this.toChildNode(e),this)),t.removeChild(this))}remove(){this.parentNode&&this.parentNode.removeChild(this)}toChildNode(e){if("string"!=typeof e)return e;const t=new TextService(e);return t.ownerDocumentStore=this.ownerDocument,t}getElementsByTagName(e){const t="*"===e?()=>!0:t=>t.tagName===e;return new HTMLCollectionService_1.HTMLCollectionService(this,t,!0)}getElementsByClassName(e){const t=e.trim().split(/\s+/).filter(Boolean);return new HTMLCollectionService_1.HTMLCollectionService(this,e=>t.every(t=>e.classList.contains(t)),!0)}querySelector(e){return(0,query_1.querySelector)(e,this)}querySelectorAll(e){return(0,query_1.querySelectorAll)(e,this)}childInserted(e){}cloneNode(e=!1){const t=this.cloneShallow();return e&&Array.from(this.childNodes).forEach(e=>t.appendChild(e.cloneNode(!0))),t}compareDocumentPosition(e){if(e===this)return 0;const t=e=>{const t=[];for(let r=e;r;r=r.parentNode)t.unshift(r);return t},r=t(this),i=t(e);if(r[0]!==i[0]){const t=e.nodeId<this.nodeId?NodeService.DOCUMENT_POSITION_PRECEDING:NodeService.DOCUMENT_POSITION_FOLLOWING;return NodeService.DOCUMENT_POSITION_DISCONNECTED|NodeService.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC|t}if(i.length<r.length&&i.every((e,t)=>r[t]===e))return NodeService.DOCUMENT_POSITION_CONTAINS|NodeService.DOCUMENT_POSITION_PRECEDING;if(r.length<i.length&&r.every((e,t)=>i[t]===e))return NodeService.DOCUMENT_POSITION_CONTAINED_BY|NodeService.DOCUMENT_POSITION_FOLLOWING;let n=0;for(;r[n]===i[n];)++n;for(let e=r[n].nextSibling;e;e=e.nextSibling)if(e===i[n])return NodeService.DOCUMENT_POSITION_FOLLOWING;return NodeService.DOCUMENT_POSITION_PRECEDING}contains(e){let t=e;for(;t;){if(t===this)return!0;t=t.parentNode}return!1}getRootNode(e={composed:!1}){return this.parent?this.parent.getRootNode(e):this}hasChildNodes(){return this.childList.length>0}insertBefore(e,t=null){if(!this.acceptsChildren)throw new Error("This kind of node cannot have children.");if(null!==t&&t.parentNode!==this)throw new Error("The node before which the new node is to be inserted is not a child of this node.");if(e===t)return e;if("function"==typeof e.contains&&e.contains(this))throw new Error("The new node cannot be inserted into itself or one of its own descendants.");if(e.nodeType===NodeService.DOCUMENT_FRAGMENT_NODE){for(;e.firstChild;)this.insertBefore(e.firstChild,t);return e}e.parentNode&&e.parentNode.removeChild(e);const r=new TreeLinker_1.TreeLinker({data:e});this.childList.insertBefore(t?t.listLinker:null,r);const i=e;return i.parent=this,i.listLinker=r,this.childInserted(i),e}isDefaultNamespace(e){return null===e}isEqualNode(e){if(!e||e.nodeType!==this.nodeType||!this.equalsShallow(e))return!1;const t=Array.from(this.childNodes),r=Array.from(e.childNodes);return t.length===r.length&&t.every((e,t)=>e.isEqualNode(r[t]))}isSameNode(e){return this===e}lookupPrefix(e){return null}lookupNamespaceURI(e){return null}normalize(){let e=this.firstChild;for(;e;)if(e.nodeType===NodeService.TEXT_NODE){let t=e.nodeValue,r=e.nextSibling;for(;r&&r.nodeType===NodeService.TEXT_NODE;){t+=r.nodeValue;const e=r.nextSibling;this.removeChild(r),r=e}e.nodeValue=t,""===t&&this.removeChild(e),e=r}else e.normalize(),e=e.nextSibling}removeChild(e){if(!e||e.parentNode!==this)throw new Error("The node to be removed is not a child of this node.");const t=e;return this.childList.remove(t.listLinker),t.parent=null,t.listLinker=null,e}replaceChild(e,t){if(!t||t.parentNode!==this)throw new Error("The node to be replaced is not a child of this node.");if(e===t)return t;let r=t.nextSibling;return r===e&&(r=e.nextSibling),this.removeChild(t),this.insertBefore(e,r),t}}exports.NodeService=NodeService,NodeService.DEFAULT_NODE=0,NodeService.ELEMENT_NODE=1,NodeService.ATTRIBUTE_NODE=2,NodeService.TEXT_NODE=3,NodeService.CDATA_SECTION_NODE=4,NodeService.ENTITY_REFERENCE_NODE=5,NodeService.ENTITY_NODE=6,NodeService.PROCESSING_INSTRUCTION_NODE=7,NodeService.COMMENT_NODE=8,NodeService.DOCUMENT_NODE=9,NodeService.DOCUMENT_TYPE_NODE=10,NodeService.DOCUMENT_FRAGMENT_NODE=11,NodeService.NOTATION_NODE=12,NodeService.DOCUMENT_POSITION_DISCONNECTED=1,NodeService.DOCUMENT_POSITION_PRECEDING=2,NodeService.DOCUMENT_POSITION_FOLLOWING=4,NodeService.DOCUMENT_POSITION_CONTAINS=8,NodeService.DOCUMENT_POSITION_CONTAINED_BY=16,NodeService.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC=32,NodeService.nextNodeId=1;class TextService extends NodeService{constructor(e=""){super(),this.nodeValue=String(e)}get acceptsChildren(){return!1}get nodeName(){return"#text"}get nodeType(){return NodeService.TEXT_NODE}get data(){return this.nodeValue}set data(e){this.nodeValue=String(e)}get length(){return this.data.length}get textContent(){return this.data}set textContent(e){this.data=null===e?"":String(e)}get wholeText(){let e=this;for(;e.previousSibling&&e.previousSibling.nodeType===NodeService.TEXT_NODE;)e=e.previousSibling;let t="";for(let r=e;r&&r.nodeType===NodeService.TEXT_NODE;r=r.nextSibling)t+=r.nodeValue;return t}splitText(e){if(e<0||e>this.length)throw new Error("The offset is beyond the end of the text.");const t=new TextService(this.data.slice(e));return t.ownerDocumentStore=this.ownerDocumentStore,this.data=this.data.slice(0,e),this.parentNode&&this.parentNode.insertBefore(t,this.nextSibling),t}cloneShallow(){const e=new TextService(this.data);return e.ownerDocumentStore=this.ownerDocumentStore,e}}exports.TextService=TextService;class CommentService extends NodeService{constructor(e=""){super(),this.nodeValue=String(e)}get acceptsChildren(){return!1}get nodeName(){return"#comment"}get nodeType(){return NodeService.COMMENT_NODE}get data(){return this.nodeValue}set data(e){this.nodeValue=String(e)}get length(){return this.data.length}get textContent(){return this.data}set textContent(e){this.data=null===e?"":String(e)}cloneShallow(){const e=new CommentService(this.data);return e.ownerDocumentStore=this.ownerDocumentStore,e}}exports.CommentService=CommentService;
|
|
1
|
+
"use strict";require("core-js/modules/esnext.iterator.constructor.js"),require("core-js/modules/esnext.iterator.every.js"),require("core-js/modules/esnext.iterator.filter.js"),require("core-js/modules/esnext.iterator.for-each.js");var __importDefault=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.CommentService=exports.TextService=exports.NodeService=void 0;const generateNodeList_1=__importDefault(require("../factories/generateNodeList")),TreeLinker_1=require("collect-your-stuff/dist/collections/linked-tree-list/TreeLinker"),EventTargetService_1=__importDefault(require("./EventTargetService")),HTMLCollectionService_1=require("./HTMLCollectionService"),query_1=require("../factories/query");class NodeService extends EventTargetService_1.default{constructor(){super(),this.nodeValueStore=null,this.ownerDocumentStore=null,this.nodeId=NodeService.nextNodeId++,this.nodeNameValue="",this.childList=(0,generateNodeList_1.default)(),this.parent=null,this.listLinker=null}get baseURI(){return window.location||"/"}get childNodes(){return this.childList}get firstChild(){return this.childList.first?this.childList.first.data:null}get isConnected(){return this.getRootNode().nodeType===NodeService.DOCUMENT_NODE}get lastChild(){return this.childList.last?this.childList.last.data:null}get nextSibling(){return this.listLinker&&this.listLinker.next?this.listLinker.next.data:null}get nodeName(){return this.nodeNameValue||""}get nodeType(){return NodeService.DEFAULT_NODE}get nodeValue(){return this.nodeValueStore}set nodeValue(e){this.nodeValueStore=e}get ownerDocument(){if(this.nodeType===NodeService.DOCUMENT_NODE)return null;const e=this.getRootNode();return e.nodeType===NodeService.DOCUMENT_NODE?e:this.ownerDocumentStore}get parentNode(){return this.parent}get parentElement(){return this.parent&&this.parent.nodeType===NodeService.ELEMENT_NODE?this.parent:null}get previousSibling(){return this.listLinker&&this.listLinker.prev?this.listLinker.prev.data:null}get textContent(){if(this.nodeType===NodeService.DOCUMENT_NODE||this.nodeType===NodeService.DOCUMENT_TYPE_NODE)return null;let e="";return Array.from(this.childNodes).forEach(t=>{t.nodeType===NodeService.TEXT_NODE?e+=t.nodeValue:t.nodeType!==NodeService.COMMENT_NODE&&(e+=t.textContent)}),e}set textContent(e){if(this.nodeType!==NodeService.DOCUMENT_NODE&&this.nodeType!==NodeService.DOCUMENT_TYPE_NODE){for(;this.firstChild;)this.removeChild(this.firstChild);if(null!=e&&""!==String(e)){const t=new TextService(String(e));t.ownerDocumentStore=this.ownerDocument,this.appendChild(t)}}}appendChild(e){return this.insertBefore(e,null)}get acceptsChildren(){return!0}cloneShallow(){const e=new this.constructor;return e.nodeValue=this.nodeValue,e.ownerDocumentStore=this.ownerDocumentStore,e}equalsShallow(e){return this.nodeName===e.nodeName&&this.nodeValue===e.nodeValue}append(...e){e.forEach(e=>this.appendChild(this.toChildNode(e)))}prepend(...e){const t=this.firstChild;e.forEach(e=>this.insertBefore(this.toChildNode(e),t))}replaceChildren(...e){for(;this.firstChild;)this.removeChild(this.firstChild);this.append(...e)}before(...e){const t=this.parentNode;t&&e.forEach(e=>t.insertBefore(this.toChildNode(e),this))}after(...e){const t=this.parentNode;if(!t)return;const r=this.nextSibling;e.forEach(e=>t.insertBefore(this.toChildNode(e),r))}replaceWith(...e){const t=this.parentNode;t&&(e.forEach(e=>t.insertBefore(this.toChildNode(e),this)),t.removeChild(this))}remove(){this.parentNode&&this.parentNode.removeChild(this)}toChildNode(e){if("string"!=typeof e)return e;const t=new TextService(e);return t.ownerDocumentStore=this.ownerDocument,t}getElementsByTagName(e){const t="*"===e?()=>!0:t=>t.tagName===e;return new HTMLCollectionService_1.HTMLCollectionService(this,t,!0)}getElementsByClassName(e){const t=e.trim().split(/\s+/).filter(Boolean);return new HTMLCollectionService_1.HTMLCollectionService(this,e=>t.every(t=>e.classList.contains(t)),!0)}getElementsByTagNameNS(e,t){return this.getElementsByTagName(t)}querySelector(e){return(0,query_1.querySelector)(e,this)}querySelectorAll(e){return(0,query_1.querySelectorAll)(e,this)}childInserted(e){}cloneNode(e=!1){const t=this.cloneShallow();return e&&Array.from(this.childNodes).forEach(e=>t.appendChild(e.cloneNode(!0))),t}compareDocumentPosition(e){if(e===this)return 0;const t=e=>{const t=[];for(let r=e;r;r=r.parentNode)t.unshift(r);return t},r=t(this),i=t(e);if(r[0]!==i[0]){const t=e.nodeId<this.nodeId?NodeService.DOCUMENT_POSITION_PRECEDING:NodeService.DOCUMENT_POSITION_FOLLOWING;return NodeService.DOCUMENT_POSITION_DISCONNECTED|NodeService.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC|t}if(i.length<r.length&&i.every((e,t)=>r[t]===e))return NodeService.DOCUMENT_POSITION_CONTAINS|NodeService.DOCUMENT_POSITION_PRECEDING;if(r.length<i.length&&r.every((e,t)=>i[t]===e))return NodeService.DOCUMENT_POSITION_CONTAINED_BY|NodeService.DOCUMENT_POSITION_FOLLOWING;let n=0;for(;r[n]===i[n];)++n;for(let e=r[n].nextSibling;e;e=e.nextSibling)if(e===i[n])return NodeService.DOCUMENT_POSITION_FOLLOWING;return NodeService.DOCUMENT_POSITION_PRECEDING}contains(e){let t=e;for(;t;){if(t===this)return!0;t=t.parentNode}return!1}getRootNode(e={composed:!1}){return this.parent?this.parent.getRootNode(e):this}hasChildNodes(){return this.childList.length>0}insertBefore(e,t=null){if(!this.acceptsChildren)throw new Error("This kind of node cannot have children.");if(null!==t&&t.parentNode!==this)throw new Error("The node before which the new node is to be inserted is not a child of this node.");if(e===t)return e;if("function"==typeof e.contains&&e.contains(this))throw new Error("The new node cannot be inserted into itself or one of its own descendants.");if(e.nodeType===NodeService.DOCUMENT_FRAGMENT_NODE){for(;e.firstChild;)this.insertBefore(e.firstChild,t);return e}e.parentNode&&e.parentNode.removeChild(e);const r=new TreeLinker_1.TreeLinker({data:e});this.childList.insertBefore(t?t.listLinker:null,r);const i=e;return i.parent=this,i.listLinker=r,this.childInserted(i),e}isDefaultNamespace(e){return null===e}isEqualNode(e){if(!e||e.nodeType!==this.nodeType||!this.equalsShallow(e))return!1;const t=Array.from(this.childNodes),r=Array.from(e.childNodes);return t.length===r.length&&t.every((e,t)=>e.isEqualNode(r[t]))}isSameNode(e){return this===e}lookupPrefix(e){return null}lookupNamespaceURI(e){return null}normalize(){let e=this.firstChild;for(;e;)if(e.nodeType===NodeService.TEXT_NODE){let t=e.nodeValue,r=e.nextSibling;for(;r&&r.nodeType===NodeService.TEXT_NODE;){t+=r.nodeValue;const e=r.nextSibling;this.removeChild(r),r=e}e.nodeValue=t,""===t&&this.removeChild(e),e=r}else e.normalize(),e=e.nextSibling}removeChild(e){if(!e||e.parentNode!==this)throw new Error("The node to be removed is not a child of this node.");const t=e;return this.childList.remove(t.listLinker),t.parent=null,t.listLinker=null,e}replaceChild(e,t){if(!t||t.parentNode!==this)throw new Error("The node to be replaced is not a child of this node.");if(e===t)return t;let r=t.nextSibling;return r===e&&(r=e.nextSibling),this.removeChild(t),this.insertBefore(e,r),t}}exports.NodeService=NodeService,NodeService.DEFAULT_NODE=0,NodeService.ELEMENT_NODE=1,NodeService.ATTRIBUTE_NODE=2,NodeService.TEXT_NODE=3,NodeService.CDATA_SECTION_NODE=4,NodeService.ENTITY_REFERENCE_NODE=5,NodeService.ENTITY_NODE=6,NodeService.PROCESSING_INSTRUCTION_NODE=7,NodeService.COMMENT_NODE=8,NodeService.DOCUMENT_NODE=9,NodeService.DOCUMENT_TYPE_NODE=10,NodeService.DOCUMENT_FRAGMENT_NODE=11,NodeService.NOTATION_NODE=12,NodeService.DOCUMENT_POSITION_DISCONNECTED=1,NodeService.DOCUMENT_POSITION_PRECEDING=2,NodeService.DOCUMENT_POSITION_FOLLOWING=4,NodeService.DOCUMENT_POSITION_CONTAINS=8,NodeService.DOCUMENT_POSITION_CONTAINED_BY=16,NodeService.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC=32,NodeService.nextNodeId=1;class TextService extends NodeService{constructor(e=""){super(),this.nodeValue=String(e)}get acceptsChildren(){return!1}get nodeName(){return"#text"}get nodeType(){return NodeService.TEXT_NODE}get data(){return this.nodeValue}set data(e){this.nodeValue=String(e)}get length(){return this.data.length}get textContent(){return this.data}set textContent(e){this.data=null===e?"":String(e)}get wholeText(){let e=this;for(;e.previousSibling&&e.previousSibling.nodeType===NodeService.TEXT_NODE;)e=e.previousSibling;let t="";for(let r=e;r&&r.nodeType===NodeService.TEXT_NODE;r=r.nextSibling)t+=r.nodeValue;return t}splitText(e){if(e<0||e>this.length)throw new Error("The offset is beyond the end of the text.");const t=new TextService(this.data.slice(e));return t.ownerDocumentStore=this.ownerDocumentStore,this.data=this.data.slice(0,e),this.parentNode&&this.parentNode.insertBefore(t,this.nextSibling),t}cloneShallow(){const e=new TextService(this.data);return e.ownerDocumentStore=this.ownerDocumentStore,e}}exports.TextService=TextService;class CommentService extends NodeService{constructor(e=""){super(),this.nodeValue=String(e)}get acceptsChildren(){return!1}get nodeName(){return"#comment"}get nodeType(){return NodeService.COMMENT_NODE}get data(){return this.nodeValue}set data(e){this.nodeValue=String(e)}get length(){return this.data.length}get textContent(){return this.data}set textContent(e){this.data=null===e?"":String(e)}cloneShallow(){const e=new CommentService(this.data);return e.ownerDocumentStore=this.ownerDocumentStore,e}}exports.CommentService=CommentService;
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
import { DocumentFragmentService } from './DocumentFragmentService';
|
|
2
2
|
import { PseudoShadowRoot } from '../interfaces/PseudoShadowRoot';
|
|
3
|
+
import { PseudoElement } from '../interfaces/PseudoElement';
|
|
4
|
+
/**
|
|
5
|
+
* Simulate the behaviour of the ShadowRoot Class when there is no DOM available: a DocumentFragment attached to an
|
|
6
|
+
* element via attachShadow, which sets host and mode.
|
|
7
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
8
|
+
* @class
|
|
9
|
+
* @augments DocumentFragmentService
|
|
10
|
+
*/
|
|
3
11
|
export declare class ShadowRootService extends DocumentFragmentService implements PseudoShadowRoot {
|
|
12
|
+
/** The element this shadow root is attached to. Set by attachShadow. */
|
|
13
|
+
host: PseudoElement | null;
|
|
14
|
+
/** 'open' (reachable via element.shadowRoot) or 'closed' (not). Set by attachShadow. */
|
|
15
|
+
mode: string;
|
|
4
16
|
}
|
|
@@ -5,5 +5,20 @@ Object.defineProperty(exports, '__esModule', {
|
|
|
5
5
|
})
|
|
6
6
|
exports.ShadowRootService = void 0
|
|
7
7
|
const DocumentFragmentService_1 = require('./DocumentFragmentService')
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Simulate the behaviour of the ShadowRoot Class when there is no DOM available: a DocumentFragment attached to an
|
|
10
|
+
* element via attachShadow, which sets host and mode.
|
|
11
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
12
|
+
* @class
|
|
13
|
+
* @augments DocumentFragmentService
|
|
14
|
+
*/
|
|
15
|
+
class ShadowRootService extends DocumentFragmentService_1.DocumentFragmentService {
|
|
16
|
+
constructor () {
|
|
17
|
+
super(...arguments)
|
|
18
|
+
/** The element this shadow root is attached to. Set by attachShadow. */
|
|
19
|
+
this.host = null
|
|
20
|
+
/** 'open' (reachable via element.shadowRoot) or 'closed' (not). Set by attachShadow. */
|
|
21
|
+
this.mode = 'open'
|
|
22
|
+
}
|
|
23
|
+
}
|
|
9
24
|
exports.ShadowRootService = ShadowRootService
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ShadowRootService=void 0;const DocumentFragmentService_1=require("./DocumentFragmentService");class ShadowRootService extends DocumentFragmentService_1.DocumentFragmentService{}exports.ShadowRootService=ShadowRootService;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ShadowRootService=void 0;const DocumentFragmentService_1=require("./DocumentFragmentService");class ShadowRootService extends DocumentFragmentService_1.DocumentFragmentService{constructor(){super(...arguments),this.host=null,this.mode="open"}}exports.ShadowRootService=ShadowRootService;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pseudo-dom",
|
|
3
3
|
"description": "Mock the DOM on the server side for managing state and testing",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.11.0",
|
|
5
5
|
"main": "dist/main.js",
|
|
6
6
|
"types": "dist/main.d.ts",
|
|
7
7
|
"author": "Joshua Heagle",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"collect-your-stuff": "^2.1.2",
|
|
22
22
|
"core-js": "^3.50.0",
|
|
23
23
|
"css-select": "^6.0.0",
|
|
24
|
+
"htmlparser2": "^9.1.0",
|
|
24
25
|
"si-funciona": "^2.6.1"
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|