@oozcitak/dom
Advanced tools
Comparing version 0.0.12 to 1.0.0
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const SubAlgorithmImpl_1 = require("./SubAlgorithmImpl"); | ||
const util_1 = require("../util"); | ||
const DOMException_1 = require("../dom/DOMException"); | ||
const util_1 = require("../util"); | ||
/** | ||
@@ -29,3 +29,3 @@ * Contains character data algorithms. | ||
if (offset > length) { | ||
throw DOMException_1.DOMException.IndexSizeError; | ||
throw new DOMException_1.IndexSizeError(`Offset exceeds character data length. Offset: ${offset}, Length: ${length}, Node is ${node.nodeName}.`); | ||
} | ||
@@ -39,3 +39,5 @@ if (offset + count > length) { | ||
*/ | ||
this.dom.observer.queueMutationRecord("characterData", node, null, null, node.data, [], [], null, null); | ||
if (util_1.globalStore.dom.features.mutationObservers) { | ||
this.dom.observer.queueMutationRecord("characterData", node, null, null, node.data, [], [], null, null); | ||
} | ||
/** | ||
@@ -82,4 +84,4 @@ * 5. Insert data into node’s data after offset code units. | ||
*/ | ||
if (util_1.Guard.isTextNode(node) && node.parentNode !== null) { | ||
this.dom.runChildTextContentChangeSteps(node.parentNode); | ||
if (util_1.Guard.isTextNode(node) && node._parent !== null) { | ||
this.dom.runChildTextContentChangeSteps(node._parent); | ||
} | ||
@@ -101,3 +103,3 @@ } | ||
if (offset > length) { | ||
throw DOMException_1.DOMException.IndexSizeError; | ||
throw new DOMException_1.IndexSizeError(`Offset exceeds character data length. Offset: ${offset}, Length: ${length}, Node is ${node.nodeName}.`); | ||
} | ||
@@ -104,0 +106,0 @@ if (offset + count > length) { |
@@ -10,6 +10,6 @@ import { CustomElementAlgorithm, DOMAlgorithm } from './interfaces'; | ||
protected static readonly PotentialCustomElementName: RegExp; | ||
protected static readonly NamesWithHyphen: string[]; | ||
protected static readonly ElementNames: string[]; | ||
protected static readonly VoidElementNames: string[]; | ||
protected static readonly ShadowHostNames: string[]; | ||
protected static readonly NamesWithHyphen: Set<string>; | ||
protected static readonly ElementNames: Set<string>; | ||
protected static readonly VoidElementNames: Set<string>; | ||
protected static readonly ShadowHostNames: Set<string>; | ||
/** | ||
@@ -16,0 +16,0 @@ * Initializes a new `CustomElementAlgorithm`. |
@@ -18,5 +18,5 @@ "use strict"; | ||
isValidCustomElementName(name) { | ||
if (!name.match(CustomElementAlgorithmImpl.PotentialCustomElementName)) | ||
if (!CustomElementAlgorithmImpl.PotentialCustomElementName.test(name)) | ||
return false; | ||
if (CustomElementAlgorithmImpl.NamesWithHyphen.includes(name)) | ||
if (CustomElementAlgorithmImpl.NamesWithHyphen.has(name)) | ||
return false; | ||
@@ -27,11 +27,11 @@ return true; | ||
isValidElementName(name) { | ||
return (CustomElementAlgorithmImpl.ElementNames.includes(name)); | ||
return (CustomElementAlgorithmImpl.ElementNames.has(name)); | ||
} | ||
/** @inheritdoc */ | ||
isVoidElementName(name) { | ||
return (CustomElementAlgorithmImpl.VoidElementNames.includes(name)); | ||
return (CustomElementAlgorithmImpl.VoidElementNames.has(name)); | ||
} | ||
/** @inheritdoc */ | ||
isValidShadowHostName(name) { | ||
return (CustomElementAlgorithmImpl.ShadowHostNames.includes(name)); | ||
return (CustomElementAlgorithmImpl.ShadowHostNames.has(name)); | ||
} | ||
@@ -62,14 +62,14 @@ /** @inheritdoc */ | ||
CustomElementAlgorithmImpl.PotentialCustomElementName = /[a-z]([\0-\t\x2D\._a-z\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C\u200D\u203F\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])*-([\0-\t\x2D\._a-z\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C\u200D\u203F\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])*/; | ||
CustomElementAlgorithmImpl.NamesWithHyphen = ['annotation-xml', 'color-profile', | ||
CustomElementAlgorithmImpl.NamesWithHyphen = new Set(['annotation-xml', 'color-profile', | ||
'font-face', 'font-face-src', 'font-face-uri', 'font-face-format', | ||
'font-face-name', 'missing-glyph']; | ||
CustomElementAlgorithmImpl.ElementNames = ['article', 'aside', 'blockquote', | ||
'font-face-name', 'missing-glyph']); | ||
CustomElementAlgorithmImpl.ElementNames = new Set(['article', 'aside', 'blockquote', | ||
'body', 'div', 'footer', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', | ||
'header', 'main', 'nav', 'p', 'section', 'span']; | ||
CustomElementAlgorithmImpl.VoidElementNames = ['area', 'base', 'basefont', | ||
'header', 'main', 'nav', 'p', 'section', 'span']); | ||
CustomElementAlgorithmImpl.VoidElementNames = new Set(['area', 'base', 'basefont', | ||
'bgsound', 'br', 'col', 'embed', 'frame', 'hr', 'img', 'input', 'keygen', | ||
'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr']; | ||
CustomElementAlgorithmImpl.ShadowHostNames = ['article', 'aside', 'blockquote', 'body', | ||
'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr']); | ||
CustomElementAlgorithmImpl.ShadowHostNames = new Set(['article', 'aside', 'blockquote', 'body', | ||
'div', 'footer', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'main', | ||
'nav', 'p', 'section', 'span']; | ||
'nav', 'p', 'section', 'span']); | ||
//# sourceMappingURL=CustomElementAlgorithmImpl.js.map |
@@ -53,4 +53,4 @@ "use strict"; | ||
const oldDocument = node._nodeDocument; | ||
if (node.parentNode) | ||
this.dom.mutation.remove(node, node.parentNode); | ||
if (node._parent) | ||
this.dom.mutation.remove(node, node._parent); | ||
/** | ||
@@ -84,5 +84,7 @@ * 3. If document is not oldDocument, then: | ||
*/ | ||
if (util_1.Guard.isElementNode(inclusiveDescendant) && | ||
inclusiveDescendant._customElementState === "custom") { | ||
this.dom.customElement.enqueueACustomElementCallbackReaction(inclusiveDescendant, "adoptedCallback", [oldDocument, document]); | ||
if (util_1.globalStore.dom.features.customElements) { | ||
if (util_1.Guard.isElementNode(inclusiveDescendant) && | ||
inclusiveDescendant._customElementState === "custom") { | ||
this.dom.customElement.enqueueACustomElementCallbackReaction(inclusiveDescendant, "adoptedCallback", [oldDocument, document]); | ||
} | ||
} | ||
@@ -89,0 +91,0 @@ /** |
@@ -222,10 +222,10 @@ "use strict"; | ||
*/ | ||
if (toBeRemovedNode.previousSibling === null) { | ||
if (toBeRemovedNode.parentNode !== null) { | ||
nodeIterator._reference = toBeRemovedNode.parentNode; | ||
if (toBeRemovedNode._previousSibling === null) { | ||
if (toBeRemovedNode._parent !== null) { | ||
nodeIterator._reference = toBeRemovedNode._parent; | ||
} | ||
} | ||
else { | ||
let childNode = toBeRemovedNode.previousSibling; | ||
for (childNode of this.tree.getDescendantElements(toBeRemovedNode.previousSibling, true)) { | ||
let childNode = toBeRemovedNode._previousSibling; | ||
for (childNode of this.tree.getDescendantElements(toBeRemovedNode._previousSibling, true)) { | ||
// loop through to get the last descendant node | ||
@@ -232,0 +232,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const SubAlgorithmImpl_1 = require("./SubAlgorithmImpl"); | ||
const dom_1 = require("../dom"); | ||
const infra_1 = require("@oozcitak/infra"); | ||
const util_1 = require("../util"); | ||
const DOMException_1 = require("../dom/DOMException"); | ||
/** | ||
@@ -36,3 +36,5 @@ * Contains element algorithms. | ||
*/ | ||
this.dom.observer.queueAttributeMutationRecord(element, attribute._localName, attribute._namespace, attribute._value); | ||
if (util_1.globalStore.dom.features.mutationObservers) { | ||
this.dom.observer.queueAttributeMutationRecord(element, attribute._localName, attribute._namespace, attribute._value); | ||
} | ||
/** | ||
@@ -44,4 +46,6 @@ * 2. If element is custom, then enqueue a custom element callback reaction | ||
*/ | ||
if (util_1.Guard.isCustomElementNode(element)) { | ||
this.dom.customElement.enqueueACustomElementCallbackReaction(element, "attributeChangedCallback", [attribute._localName, attribute._value, value, attribute._namespace]); | ||
if (util_1.globalStore.dom.features.customElements) { | ||
if (util_1.Guard.isCustomElementNode(element)) { | ||
this.dom.customElement.enqueueACustomElementCallbackReaction(element, "attributeChangedCallback", [attribute._localName, attribute._value, value, attribute._namespace]); | ||
} | ||
} | ||
@@ -62,3 +66,5 @@ /** | ||
*/ | ||
this.dom.observer.queueAttributeMutationRecord(element, attribute._localName, attribute._namespace, null); | ||
if (util_1.globalStore.dom.features.mutationObservers) { | ||
this.dom.observer.queueAttributeMutationRecord(element, attribute._localName, attribute._namespace, null); | ||
} | ||
/** | ||
@@ -70,4 +76,6 @@ * 2. If element is custom, then enqueue a custom element callback reaction | ||
*/ | ||
if (util_1.Guard.isCustomElementNode(element)) { | ||
this.dom.customElement.enqueueACustomElementCallbackReaction(element, "attributeChangedCallback", [attribute._localName, null, attribute._value, attribute._namespace]); | ||
if (util_1.globalStore.dom.features.customElements) { | ||
if (util_1.Guard.isCustomElementNode(element)) { | ||
this.dom.customElement.enqueueACustomElementCallbackReaction(element, "attributeChangedCallback", [attribute._localName, null, attribute._value, attribute._namespace]); | ||
} | ||
} | ||
@@ -92,3 +100,5 @@ /** | ||
*/ | ||
this.dom.observer.queueAttributeMutationRecord(element, attribute._localName, attribute._namespace, attribute._value); | ||
if (util_1.globalStore.dom.features.mutationObservers) { | ||
this.dom.observer.queueAttributeMutationRecord(element, attribute._localName, attribute._namespace, attribute._value); | ||
} | ||
/** | ||
@@ -100,4 +110,6 @@ * 2. If element is custom, then enqueue a custom element callback reaction | ||
*/ | ||
if (util_1.Guard.isCustomElementNode(element)) { | ||
this.dom.customElement.enqueueACustomElementCallbackReaction(element, "attributeChangedCallback", [attribute._localName, attribute._value, null, attribute._namespace]); | ||
if (util_1.globalStore.dom.features.customElements) { | ||
if (util_1.Guard.isCustomElementNode(element)) { | ||
this.dom.customElement.enqueueACustomElementCallbackReaction(element, "attributeChangedCallback", [attribute._localName, attribute._value, null, attribute._namespace]); | ||
} | ||
} | ||
@@ -122,3 +134,5 @@ /** | ||
*/ | ||
this.dom.observer.queueAttributeMutationRecord(element, oldAttr._localName, oldAttr._namespace, oldAttr._value); | ||
if (util_1.globalStore.dom.features.mutationObservers) { | ||
this.dom.observer.queueAttributeMutationRecord(element, oldAttr._localName, oldAttr._namespace, oldAttr._value); | ||
} | ||
/** | ||
@@ -130,4 +144,6 @@ * 2. If element is custom, then enqueue a custom element callback reaction | ||
*/ | ||
if (util_1.Guard.isCustomElementNode(element)) { | ||
this.dom.customElement.enqueueACustomElementCallbackReaction(element, "attributeChangedCallback", [oldAttr._localName, oldAttr._value, newAttr._value, oldAttr._namespace]); | ||
if (util_1.globalStore.dom.features.customElements) { | ||
if (util_1.Guard.isCustomElementNode(element)) { | ||
this.dom.customElement.enqueueACustomElementCallbackReaction(element, "attributeChangedCallback", [oldAttr._localName, oldAttr._value, newAttr._value, oldAttr._namespace]); | ||
} | ||
} | ||
@@ -159,6 +175,5 @@ /** | ||
} | ||
for (const attr of element._attributeList._attributeList) { | ||
const attrInt = attr; | ||
if (attrInt._qualifiedName === qualifiedName) { | ||
return attrInt; | ||
for (const attr of (element._attributeList)._attributeList) { | ||
if (attr._qualifiedName === qualifiedName) { | ||
return attr; | ||
} | ||
@@ -176,6 +191,5 @@ } | ||
const ns = namespace || null; | ||
for (const attr of element._attributeList._attributeList) { | ||
const attrInt = attr; | ||
if (attrInt._namespace === ns && attrInt._localName === localName) { | ||
return attrInt; | ||
for (const attr of (element._attributeList)._attributeList) { | ||
if (attr._namespace === ns && attr._localName === localName) { | ||
return attr; | ||
} | ||
@@ -212,3 +226,3 @@ } | ||
if (attr._element !== null && attr._element !== element) | ||
throw dom_1.DOMException.InUseAttributeError; | ||
throw new DOMException_1.InUseAttributeError(); | ||
const oldAttr = this.getAnAttributeByNamespaceAndLocalName(attr._namespace || '', attr.localName, element); | ||
@@ -284,2 +298,9 @@ if (oldAttr === attr) | ||
let result = null; | ||
if (!util_1.globalStore.dom.features.customElements) { | ||
result = this.dom.create.element(document, localName, namespace, prefix); | ||
result._customElementState = "uncustomized"; | ||
result._customElementDefinition = null; | ||
result._is = is; | ||
return result; | ||
} | ||
/** | ||
@@ -360,11 +381,11 @@ * 4. Let definition be the result of looking up a custom element definition | ||
if (result._attributeList.length !== 0) | ||
throw dom_1.DOMException.NotSupportedError; | ||
throw new DOMException_1.NotSupportedError(); | ||
if (result._children.size !== 0) | ||
throw dom_1.DOMException.NotSupportedError; | ||
throw new DOMException_1.NotSupportedError(); | ||
if (result._parent !== null) | ||
throw dom_1.DOMException.NotSupportedError; | ||
throw new DOMException_1.NotSupportedError(); | ||
if (result._nodeDocument !== document) | ||
throw dom_1.DOMException.NotSupportedError; | ||
throw new DOMException_1.NotSupportedError(); | ||
if (result._localName !== localName) | ||
throw dom_1.DOMException.NotSupportedError; | ||
throw new DOMException_1.NotSupportedError(); | ||
/** | ||
@@ -423,3 +444,3 @@ * 6.1.10. Set result’s namespace prefix to prefix. | ||
*/ | ||
const elementInterface = this.dom.document.elementInterface(localName, infra_1.namespace.HTML); | ||
const elementInterface = this.dom.document.elementInterface(localName, namespace); | ||
result = new elementInterface(); | ||
@@ -476,3 +497,3 @@ result._localName = localName; | ||
case 'afterbegin': | ||
return this.dom.mutation.preInsert(node, element, element.firstChild); | ||
return this.dom.mutation.preInsert(node, element, element._firstChild); | ||
case 'beforeend': | ||
@@ -483,5 +504,5 @@ return this.dom.mutation.preInsert(node, element, null); | ||
return null; | ||
return this.dom.mutation.preInsert(node, element._parent, element.nextSibling); | ||
return this.dom.mutation.preInsert(node, element._parent, element._nextSibling); | ||
default: | ||
throw dom_1.DOMException.SyntaxError; | ||
throw new DOMException_1.SyntaxError(); | ||
} | ||
@@ -488,0 +509,0 @@ } |
@@ -8,2 +8,3 @@ "use strict"; | ||
const dom_1 = require("../dom"); | ||
const DOMException_1 = require("../dom/DOMException"); | ||
/** | ||
@@ -287,6 +288,5 @@ * Contains event algorithms. | ||
*/ | ||
const atImpl = activationTarget; | ||
if (activationTarget !== null && | ||
atImpl._legacyPreActivationBehavior !== undefined) { | ||
atImpl._legacyPreActivationBehavior(event); | ||
activationTarget._legacyPreActivationBehavior !== undefined) { | ||
activationTarget._legacyPreActivationBehavior(event); | ||
} | ||
@@ -775,3 +775,3 @@ /** | ||
if (constructor === null) { | ||
throw dom_1.DOMException.NotSupportedError; | ||
throw new DOMException_1.NotSupportedError(); | ||
} | ||
@@ -778,0 +778,0 @@ /** |
@@ -1,30 +0,1 @@ | ||
export { AbortAlgorithmImpl as AbortAlgorithm } from './AbortAlgorithmImpl'; | ||
export { AttrAlgorithmImpl as AttrAlgorithm } from './AttrAlgorithmImpl'; | ||
export { BoundaryPointAlgorithmImpl as BoundaryPointAlgorithm } from './BoundaryPointAlgorithmImpl'; | ||
export { CharacterDataAlgorithmImpl as CharacterDataAlgorithm } from './CharacterDataAlgorithmImpl'; | ||
export { CreateAlgorithmImpl as CreateAlgorithm } from './CreateAlgorithmImpl'; | ||
export { CustomElementAlgorithmImpl as CustomElementAlgorithm } from './CustomElementAlgorithmImpl'; | ||
export { DocumentAlgorithmImpl as DocumentAlgorithm } from './DocumentAlgorithmImpl'; | ||
export { DOMAlgorithmImpl as DOMAlgorithm } from './DOMAlgorithmImpl'; | ||
export { DOMTokenListAlgorithmImpl as DOMTokenListAlgorithm } from './DOMTokenListAlgorithmImpl'; | ||
export { ElementAlgorithmImpl as ElementAlgorithm } from './ElementAlgorithmImpl'; | ||
export { EventAlgorithmImpl as EventAlgorithm } from './EventAlgorithmImpl'; | ||
export { EventTargetAlgorithmImpl as EventTargetAlgorithm } from './EventTargetAlgorithmImpl'; | ||
export { MutationAlgorithmImpl as MutationAlgorithm } from './MutationAlgorithmImpl'; | ||
export { MutationObserverAlgorithmImpl as MutationObserverAlgorithm } from './MutationObserverAlgorithmImpl'; | ||
export { NamespaceAlgorithmImpl as NamespaceAlgorithm } from './NamespaceAlgorithmImpl'; | ||
export { NodeAlgorithmImpl as NodeAlgorithm } from './NodeAlgorithmImpl'; | ||
export { NodeIteratorAlgorithmImpl as NodeIteratorAlgorithm } from './NodeIteratorAlgorithmImpl'; | ||
export { OrderedSetAlgorithmImpl as OrderedSetAlgorithm } from './OrderedSetAlgorithmImpl'; | ||
export { ParentNodeAlgorithmImpl as ParentNodeAlgorithm } from './ParentNodeAlgorithmImpl'; | ||
export { RangeAlgorithmImpl as RangeAlgorithm } from './RangeAlgorithmImpl'; | ||
export { SelectorsAlgorithmImpl as SelectorsAlgorithm } from './SelectorsAlgorithmImpl'; | ||
export { ShadowTreeAlgorithmImpl as ShadowTreeAlgorithm } from './ShadowTreeAlgorithmImpl'; | ||
export { SubAlgorithmImpl as SubAlgorithm } from './SubAlgorithmImpl'; | ||
export { TextAlgorithmImpl as TextAlgorithm } from './TextAlgorithmImpl'; | ||
export { TraversalAlgorithmImpl as TraversalAlgorithm } from './TraversalAlgorithmImpl'; | ||
export { TreeAlgorithmImpl as TreeAlgorithm } from './TreeAlgorithmImpl'; | ||
export { TreeWalkerAlgorithmImpl as TreeWalkerAlgorithm } from './TreeWalkerAlgorithmImpl'; | ||
export { XMLAlgorithmImpl as XMLAlgorithm } from './XMLAlgorithmImpl'; | ||
import * as Interfaces from './interfaces'; | ||
export { Interfaces }; |
"use strict"; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// Export classes | ||
var AbortAlgorithmImpl_1 = require("./AbortAlgorithmImpl"); | ||
exports.AbortAlgorithm = AbortAlgorithmImpl_1.AbortAlgorithmImpl; | ||
var AttrAlgorithmImpl_1 = require("./AttrAlgorithmImpl"); | ||
exports.AttrAlgorithm = AttrAlgorithmImpl_1.AttrAlgorithmImpl; | ||
var BoundaryPointAlgorithmImpl_1 = require("./BoundaryPointAlgorithmImpl"); | ||
exports.BoundaryPointAlgorithm = BoundaryPointAlgorithmImpl_1.BoundaryPointAlgorithmImpl; | ||
var CharacterDataAlgorithmImpl_1 = require("./CharacterDataAlgorithmImpl"); | ||
exports.CharacterDataAlgorithm = CharacterDataAlgorithmImpl_1.CharacterDataAlgorithmImpl; | ||
var CreateAlgorithmImpl_1 = require("./CreateAlgorithmImpl"); | ||
exports.CreateAlgorithm = CreateAlgorithmImpl_1.CreateAlgorithmImpl; | ||
var CustomElementAlgorithmImpl_1 = require("./CustomElementAlgorithmImpl"); | ||
exports.CustomElementAlgorithm = CustomElementAlgorithmImpl_1.CustomElementAlgorithmImpl; | ||
var DocumentAlgorithmImpl_1 = require("./DocumentAlgorithmImpl"); | ||
exports.DocumentAlgorithm = DocumentAlgorithmImpl_1.DocumentAlgorithmImpl; | ||
var DOMAlgorithmImpl_1 = require("./DOMAlgorithmImpl"); | ||
exports.DOMAlgorithm = DOMAlgorithmImpl_1.DOMAlgorithmImpl; | ||
var DOMTokenListAlgorithmImpl_1 = require("./DOMTokenListAlgorithmImpl"); | ||
exports.DOMTokenListAlgorithm = DOMTokenListAlgorithmImpl_1.DOMTokenListAlgorithmImpl; | ||
var ElementAlgorithmImpl_1 = require("./ElementAlgorithmImpl"); | ||
exports.ElementAlgorithm = ElementAlgorithmImpl_1.ElementAlgorithmImpl; | ||
var EventAlgorithmImpl_1 = require("./EventAlgorithmImpl"); | ||
exports.EventAlgorithm = EventAlgorithmImpl_1.EventAlgorithmImpl; | ||
var EventTargetAlgorithmImpl_1 = require("./EventTargetAlgorithmImpl"); | ||
exports.EventTargetAlgorithm = EventTargetAlgorithmImpl_1.EventTargetAlgorithmImpl; | ||
var MutationAlgorithmImpl_1 = require("./MutationAlgorithmImpl"); | ||
exports.MutationAlgorithm = MutationAlgorithmImpl_1.MutationAlgorithmImpl; | ||
var MutationObserverAlgorithmImpl_1 = require("./MutationObserverAlgorithmImpl"); | ||
exports.MutationObserverAlgorithm = MutationObserverAlgorithmImpl_1.MutationObserverAlgorithmImpl; | ||
var NamespaceAlgorithmImpl_1 = require("./NamespaceAlgorithmImpl"); | ||
exports.NamespaceAlgorithm = NamespaceAlgorithmImpl_1.NamespaceAlgorithmImpl; | ||
var NodeAlgorithmImpl_1 = require("./NodeAlgorithmImpl"); | ||
exports.NodeAlgorithm = NodeAlgorithmImpl_1.NodeAlgorithmImpl; | ||
var NodeIteratorAlgorithmImpl_1 = require("./NodeIteratorAlgorithmImpl"); | ||
exports.NodeIteratorAlgorithm = NodeIteratorAlgorithmImpl_1.NodeIteratorAlgorithmImpl; | ||
var OrderedSetAlgorithmImpl_1 = require("./OrderedSetAlgorithmImpl"); | ||
exports.OrderedSetAlgorithm = OrderedSetAlgorithmImpl_1.OrderedSetAlgorithmImpl; | ||
var ParentNodeAlgorithmImpl_1 = require("./ParentNodeAlgorithmImpl"); | ||
exports.ParentNodeAlgorithm = ParentNodeAlgorithmImpl_1.ParentNodeAlgorithmImpl; | ||
var RangeAlgorithmImpl_1 = require("./RangeAlgorithmImpl"); | ||
exports.RangeAlgorithm = RangeAlgorithmImpl_1.RangeAlgorithmImpl; | ||
var SelectorsAlgorithmImpl_1 = require("./SelectorsAlgorithmImpl"); | ||
exports.SelectorsAlgorithm = SelectorsAlgorithmImpl_1.SelectorsAlgorithmImpl; | ||
var ShadowTreeAlgorithmImpl_1 = require("./ShadowTreeAlgorithmImpl"); | ||
exports.ShadowTreeAlgorithm = ShadowTreeAlgorithmImpl_1.ShadowTreeAlgorithmImpl; | ||
var SubAlgorithmImpl_1 = require("./SubAlgorithmImpl"); | ||
exports.SubAlgorithm = SubAlgorithmImpl_1.SubAlgorithmImpl; | ||
var TextAlgorithmImpl_1 = require("./TextAlgorithmImpl"); | ||
exports.TextAlgorithm = TextAlgorithmImpl_1.TextAlgorithmImpl; | ||
var TraversalAlgorithmImpl_1 = require("./TraversalAlgorithmImpl"); | ||
exports.TraversalAlgorithm = TraversalAlgorithmImpl_1.TraversalAlgorithmImpl; | ||
var TreeAlgorithmImpl_1 = require("./TreeAlgorithmImpl"); | ||
exports.TreeAlgorithm = TreeAlgorithmImpl_1.TreeAlgorithmImpl; | ||
var TreeWalkerAlgorithmImpl_1 = require("./TreeWalkerAlgorithmImpl"); | ||
exports.TreeWalkerAlgorithm = TreeWalkerAlgorithmImpl_1.TreeWalkerAlgorithmImpl; | ||
var XMLAlgorithmImpl_1 = require("./XMLAlgorithmImpl"); | ||
exports.XMLAlgorithm = XMLAlgorithmImpl_1.XMLAlgorithmImpl; | ||
// Export interfaces | ||
const Interfaces = __importStar(require("./interfaces")); | ||
exports.Interfaces = Interfaces; | ||
//# sourceMappingURL=index.js.map |
@@ -232,3 +232,3 @@ import { Node, Document, Element, HTMLCollection, Attr, DOMImplementation, DocumentType, DocumentFragment, Text, CDATASection, Comment, ProcessingInstruction, NodeList, NamedNodeMap, Range, NodeIterator, TreeWalker, NodeFilter, Event, EventTarget, AbortSignal, Slotable, Slot, MutationRecord, CharacterData, XMLDocument, DOMTokenList, ShadowRoot, AbstractRange, AbortController, Window, AddEventListenerOptions, EventListenerOptions, EventListenerEntry, PotentialEventTarget, EventPathItem, BoundaryPoint, BoundaryPosition, FilterResult, CustomElementDefinition, EventHandler } from "../dom/interfaces"; | ||
*/ | ||
getDescendantNodes(node: Node, self?: boolean, shadow?: boolean, filter?: (childNode: Node) => any): IterableIterator<Node>; | ||
getDescendantNodes(node: Node, self?: boolean, shadow?: boolean, filter?: (childNode: Node) => boolean): Iterable<Node>; | ||
/** | ||
@@ -243,3 +243,3 @@ * Traverses through all descendant element nodes of the tree rooted at | ||
*/ | ||
getDescendantElements(node: Node, self?: boolean, shadow?: boolean, filter?: (childNode: Element) => any): IterableIterator<Element>; | ||
getDescendantElements(node: Node, self?: boolean, shadow?: boolean, filter?: (childNode: Element) => boolean): Iterable<Element>; | ||
/** | ||
@@ -252,3 +252,3 @@ * Traverses through all sibling nodes of `node`. | ||
*/ | ||
getSiblingNodes(node: Node, self?: boolean, filter?: (childNode: Node) => any): IterableIterator<Node>; | ||
getSiblingNodes(node: Node, self?: boolean, filter?: (childNode: Node) => boolean): Iterable<Node>; | ||
/** | ||
@@ -261,3 +261,3 @@ * Traverses through all ancestor nodes `node` in reverse tree order. | ||
*/ | ||
getAncestorNodes(node: Node, self?: boolean, filter?: (ancestorNode: Node) => any): IterableIterator<Node>; | ||
getAncestorNodes(node: Node, self?: boolean, filter?: (ancestorNode: Node) => boolean): Iterable<Node>; | ||
/** | ||
@@ -1062,3 +1062,3 @@ * Returns the common ancestor of the given nodes. | ||
*/ | ||
contiguousTextNodes(node: Text, self?: boolean): IterableIterator<Text>; | ||
contiguousTextNodes(node: Text, self?: boolean): Iterable<Text>; | ||
/** | ||
@@ -1070,3 +1070,3 @@ * Returns node with its adjacent text node siblings. | ||
*/ | ||
contiguousExclusiveTextNodes(node: Text, self?: boolean): IterableIterator<Text>; | ||
contiguousExclusiveTextNodes(node: Text, self?: boolean): Iterable<Text>; | ||
/** | ||
@@ -1314,3 +1314,3 @@ * Returns the concatenation of the data of all the Text node descendants of | ||
*/ | ||
htmlCollection(root: Node, filter?: ((element: Element) => any)): HTMLCollection; | ||
htmlCollection(root: Node, filter?: ((element: Element) => boolean)): HTMLCollection; | ||
/** | ||
@@ -1498,3 +1498,3 @@ * Creates a new live `NodeList`. | ||
*/ | ||
getContainedNodes(range: AbstractRange): IterableIterator<Node>; | ||
getContainedNodes(range: AbstractRange): Iterable<Node>; | ||
/** | ||
@@ -1505,3 +1505,3 @@ * Traverses through all partially contained nodes of a range. | ||
*/ | ||
getPartiallyContainedNodes(range: AbstractRange): IterableIterator<Node>; | ||
getPartiallyContainedNodes(range: AbstractRange): Iterable<Node>; | ||
/** | ||
@@ -1508,0 +1508,0 @@ * Gets the global range list. |
@@ -30,3 +30,3 @@ "use strict"; | ||
parent.nodeType !== interfaces_1.NodeType.Element) | ||
throw DOMException_1.DOMException.HierarchyRequestError; | ||
throw new DOMException_1.HierarchyRequestError(`Only document, document fragment and element nodes can contain child nodes. Parent node is ${parent.nodeName}.`); | ||
/** | ||
@@ -37,3 +37,3 @@ * 2. If node is a host-including inclusive ancestor of parent, throw a | ||
if (this.dom.tree.isAncestorOf(parent, node, true, true)) | ||
throw DOMException_1.DOMException.HierarchyRequestError; | ||
throw new DOMException_1.HierarchyRequestError(`The node to be inserted cannot be an ancestor of parent node. Node is ${node.nodeName}, parent node is ${parent.nodeName}.`); | ||
/** | ||
@@ -43,4 +43,4 @@ * 3. If child is not null and its parent is not parent, then throw a | ||
*/ | ||
if (child !== null && child.parentNode !== parent) | ||
throw DOMException_1.DOMException.NotFoundError; | ||
if (child !== null && child._parent !== parent) | ||
throw new DOMException_1.NotFoundError(`The reference child node cannot be found under parent node. Child node is ${child.nodeName}, parent node is ${parent.nodeName}.`); | ||
/** | ||
@@ -58,3 +58,3 @@ * 4. If node is not a DocumentFragment, DocumentType, Element, Text, | ||
node.nodeType !== interfaces_1.NodeType.Comment) | ||
throw DOMException_1.DOMException.HierarchyRequestError; | ||
throw new DOMException_1.HierarchyRequestError(`Only document fragment, document type, element, text, processing instruction, cdata section or comment nodes can be inserted. Node is ${node.nodeName}.`); | ||
/** | ||
@@ -67,6 +67,6 @@ * 5. If either node is a Text node and parent is a document, or node is a | ||
parent.nodeType === interfaces_1.NodeType.Document) | ||
throw DOMException_1.DOMException.HierarchyRequestError; | ||
throw new DOMException_1.HierarchyRequestError(`Cannot insert a text node as a child of a document node. Node is ${node.nodeName}.`); | ||
if (node.nodeType === interfaces_1.NodeType.DocumentType && | ||
parent.nodeType !== interfaces_1.NodeType.Document) | ||
throw DOMException_1.DOMException.HierarchyRequestError; | ||
throw new DOMException_1.HierarchyRequestError(`A document type node can only be inserted under a document node. Parent node is ${parent.nodeName}.`); | ||
/** | ||
@@ -90,23 +90,24 @@ * 6. If parent is a document, and any of the statements below, switched on | ||
let eleCount = 0; | ||
for (const childNode of node.childNodes) { | ||
for (const childNode of node._children) { | ||
if (childNode.nodeType === interfaces_1.NodeType.Element) | ||
eleCount++; | ||
else if (childNode.nodeType === interfaces_1.NodeType.Text) | ||
throw DOMException_1.DOMException.HierarchyRequestError; | ||
if (eleCount > 1) | ||
throw DOMException_1.DOMException.HierarchyRequestError; | ||
throw new DOMException_1.HierarchyRequestError(`Cannot insert text a node as a child of a document node. Node is ${childNode.nodeName}.`); | ||
} | ||
if (eleCount === 1) { | ||
for (const ele of parent.childNodes) { | ||
if (eleCount > 1) { | ||
throw new DOMException_1.HierarchyRequestError(`A document node can only have one document element node. Document fragment to be inserted has ${eleCount} element nodes.`); | ||
} | ||
else if (eleCount === 1) { | ||
for (const ele of parent._children) { | ||
if (ele.nodeType === interfaces_1.NodeType.Element) | ||
throw DOMException_1.DOMException.HierarchyRequestError; | ||
throw new DOMException_1.HierarchyRequestError(`The document node already has a document element node.`); | ||
} | ||
if (child) { | ||
if (child.nodeType === interfaces_1.NodeType.DocumentType) | ||
throw DOMException_1.DOMException.HierarchyRequestError; | ||
let doctypeChild = child.nextSibling; | ||
throw new DOMException_1.HierarchyRequestError(`Cannot insert an element node before a document type node.`); | ||
let doctypeChild = child._nextSibling; | ||
while (doctypeChild) { | ||
if (doctypeChild.nodeType === interfaces_1.NodeType.DocumentType) | ||
throw DOMException_1.DOMException.HierarchyRequestError; | ||
doctypeChild = doctypeChild.nextSibling; | ||
throw new DOMException_1.HierarchyRequestError(`Cannot insert an element node before a document type node.`); | ||
doctypeChild = doctypeChild._nextSibling; | ||
} | ||
@@ -117,14 +118,14 @@ } | ||
else if (node.nodeType === interfaces_1.NodeType.Element) { | ||
for (const ele of parent.childNodes) { | ||
for (const ele of parent._children) { | ||
if (ele.nodeType === interfaces_1.NodeType.Element) | ||
throw DOMException_1.DOMException.HierarchyRequestError; | ||
throw new DOMException_1.HierarchyRequestError(`Document already has a document element node. Node is ${node.nodeName}.`); | ||
} | ||
if (child) { | ||
if (child.nodeType === interfaces_1.NodeType.DocumentType) | ||
throw DOMException_1.DOMException.HierarchyRequestError; | ||
let doctypeChild = child.nextSibling; | ||
throw new DOMException_1.HierarchyRequestError(`Cannot insert an element node before a document type node. Node is ${node.nodeName}.`); | ||
let doctypeChild = child._nextSibling; | ||
while (doctypeChild) { | ||
if (doctypeChild.nodeType === interfaces_1.NodeType.DocumentType) | ||
throw DOMException_1.DOMException.HierarchyRequestError; | ||
doctypeChild = doctypeChild.nextSibling; | ||
throw new DOMException_1.HierarchyRequestError(`Cannot insert an element node before a document type node. Node is ${node.nodeName}.`); | ||
doctypeChild = doctypeChild._nextSibling; | ||
} | ||
@@ -134,20 +135,20 @@ } | ||
else if (node.nodeType === interfaces_1.NodeType.DocumentType) { | ||
for (const ele of parent.childNodes) { | ||
for (const ele of parent._children) { | ||
if (ele.nodeType === interfaces_1.NodeType.DocumentType) | ||
throw DOMException_1.DOMException.HierarchyRequestError; | ||
throw new DOMException_1.HierarchyRequestError(`Document already has a document type node. Node is ${node.nodeName}.`); | ||
} | ||
if (child) { | ||
let elementChild = child.previousSibling; | ||
let elementChild = child._previousSibling; | ||
while (elementChild) { | ||
if (elementChild.nodeType === interfaces_1.NodeType.Element) | ||
throw DOMException_1.DOMException.HierarchyRequestError; | ||
elementChild = elementChild.previousSibling; | ||
throw new DOMException_1.HierarchyRequestError(`Cannot insert a document type node before an element node. Node is ${node.nodeName}.`); | ||
elementChild = elementChild._previousSibling; | ||
} | ||
} | ||
else { | ||
let elementChild = parent.firstChild; | ||
let elementChild = parent._firstChild; | ||
while (elementChild) { | ||
if (elementChild.nodeType === interfaces_1.NodeType.Element) | ||
throw DOMException_1.DOMException.HierarchyRequestError; | ||
elementChild = elementChild.nextSibling; | ||
throw new DOMException_1.HierarchyRequestError(`Cannot insert a document type node before an element node. Node is ${node.nodeName}.`); | ||
elementChild = elementChild._nextSibling; | ||
} | ||
@@ -171,3 +172,3 @@ } | ||
if (referenceChild === node) | ||
referenceChild = node.nextSibling; | ||
referenceChild = node._nextSibling; | ||
this.dom.document.adopt(node, parent._nodeDocument); | ||
@@ -184,3 +185,3 @@ this.insert(node, parent, referenceChild); | ||
const count = (node.nodeType === interfaces_1.NodeType.DocumentFragment ? | ||
node.childNodes.length : 1); | ||
node._children.size : 1); | ||
/** | ||
@@ -198,10 +199,12 @@ * 2. If child is non-null, then: | ||
*/ | ||
const index = this.dom.tree.index(child); | ||
for (const range of this.dom.range.rangeList) { | ||
if (range._start[0] === parent && range._start[1] > index) { | ||
range._start[1] += count; | ||
if (this.dom.range.rangeList.length !== 0) { | ||
const index = this.dom.tree.index(child); | ||
for (const range of this.dom.range.rangeList) { | ||
if (range._start[0] === parent && range._start[1] > index) { | ||
range._start[1] += count; | ||
} | ||
if (range._end[0] === parent && range._end[1] > index) { | ||
range._end[1] += count; | ||
} | ||
} | ||
if (range._end[0] === parent && range._end[1] > index) { | ||
range._end[1] += count; | ||
} | ||
} | ||
@@ -212,18 +215,14 @@ } | ||
* otherwise « node ». | ||
*/ | ||
const nodes = node.nodeType === interfaces_1.NodeType.DocumentFragment ? | ||
new Array(...node._children) : [node]; | ||
/** | ||
* 4. If node is a DocumentFragment node, remove its children with the | ||
* suppress observers flag set. | ||
*/ | ||
const nodes = []; | ||
if (node.nodeType === interfaces_1.NodeType.DocumentFragment) { | ||
for (const childNode of node.childNodes) { | ||
nodes.push(childNode); | ||
while (node._firstChild) { | ||
this.remove(node._firstChild, node, true); | ||
} | ||
// remove child nodes | ||
while (node.firstChild) { | ||
this.remove(node.firstChild, node, true); | ||
} | ||
} | ||
else { | ||
nodes.push(node); | ||
} | ||
/** | ||
@@ -233,4 +232,6 @@ * 5. If node is a DocumentFragment node, then queue a tree mutation record | ||
*/ | ||
if (util_1.Guard.isDocumentFragmentNode(node)) { | ||
this.dom.observer.queueTreeMutationRecord(node, [], nodes, null, null); | ||
if (util_1.globalStore.dom.features.mutationObservers) { | ||
if (node.nodeType === interfaces_1.NodeType.DocumentFragment) { | ||
this.dom.observer.queueTreeMutationRecord(node, [], nodes, null, null); | ||
} | ||
} | ||
@@ -241,3 +242,3 @@ /** | ||
*/ | ||
const previousSibling = (child ? child.previousSibling : parent.lastChild); | ||
const previousSibling = (child ? child._previousSibling : parent._lastChild); | ||
let index = child === null ? -1 : this.dom.tree.index(child); | ||
@@ -263,3 +264,3 @@ /** | ||
// assign siblings and children for quick lookups | ||
if (parent.firstChild === null) { | ||
if (parent._firstChild === null) { | ||
node._previousSibling = null; | ||
@@ -271,3 +272,3 @@ node._nextSibling = null; | ||
else { | ||
const prev = (child ? child.previousSibling : parent.lastChild); | ||
const prev = (child ? child._previousSibling : parent._lastChild); | ||
const next = (child ? child : null); | ||
@@ -290,4 +291,6 @@ node._previousSibling = prev; | ||
*/ | ||
if (parent._shadowRoot !== null && util_1.Guard.isSlotable(node)) { | ||
this.dom.shadowTree.assignASlot(node); | ||
if (util_1.globalStore.dom.features.slots) { | ||
if (parent._shadowRoot !== null && util_1.Guard.isSlotable(node)) { | ||
this.dom.shadowTree.assignASlot(node); | ||
} | ||
} | ||
@@ -306,5 +309,7 @@ /** | ||
*/ | ||
if (util_1.Guard.isShadowRoot(this.dom.tree.rootNode(parent)) && | ||
util_1.Guard.isSlot(parent) && util_2.isEmpty(parent._assignedNodes)) { | ||
this.dom.shadowTree.signalASlotChange(parent); | ||
if (util_1.globalStore.dom.features.slots) { | ||
if (util_1.Guard.isShadowRoot(this.dom.tree.rootNode(parent)) && | ||
util_1.Guard.isSlot(parent) && util_2.isEmpty(parent._assignedNodes)) { | ||
this.dom.shadowTree.signalASlotChange(parent); | ||
} | ||
} | ||
@@ -314,3 +319,5 @@ /** | ||
*/ | ||
this.dom.shadowTree.assignSlotablesForATree(this.dom.tree.rootNode(node)); | ||
if (util_1.globalStore.dom.features.slots) { | ||
this.dom.shadowTree.assignSlotablesForATree(this.dom.tree.rootNode(node)); | ||
} | ||
/** | ||
@@ -326,21 +333,23 @@ * 7.7. For each shadow-including inclusive descendant | ||
this.dom.runInsertionSteps(inclusiveDescendant); | ||
/** | ||
* 7.7.2. If inclusiveDescendant is connected, then: | ||
*/ | ||
if (util_1.Guard.isElementNode(inclusiveDescendant) && | ||
this.dom.shadowTree.isConnected(inclusiveDescendant)) { | ||
if (util_1.Guard.isCustomElementNode(inclusiveDescendant)) { | ||
/** | ||
* 7.7.2.1. If inclusiveDescendant is custom, then enqueue a custom | ||
* element callback reaction with inclusiveDescendant, callback name | ||
* "connectedCallback", and an empty argument list. | ||
*/ | ||
this.dom.customElement.enqueueACustomElementCallbackReaction(inclusiveDescendant, "connectedCallback", []); | ||
if (util_1.globalStore.dom.features.customElements) { | ||
/** | ||
* 7.7.2. If inclusiveDescendant is connected, then: | ||
*/ | ||
if (util_1.Guard.isElementNode(inclusiveDescendant) && | ||
this.dom.shadowTree.isConnected(inclusiveDescendant)) { | ||
if (util_1.Guard.isCustomElementNode(inclusiveDescendant)) { | ||
/** | ||
* 7.7.2.1. If inclusiveDescendant is custom, then enqueue a custom | ||
* element callback reaction with inclusiveDescendant, callback name | ||
* "connectedCallback", and an empty argument list. | ||
*/ | ||
this.dom.customElement.enqueueACustomElementCallbackReaction(inclusiveDescendant, "connectedCallback", []); | ||
} | ||
else { | ||
/** | ||
* 7.7.2.2. Otherwise, try to upgrade inclusiveDescendant. | ||
*/ | ||
this.dom.customElement.tryToUpgrade(inclusiveDescendant); | ||
} | ||
} | ||
else { | ||
/** | ||
* 7.7.2.2. Otherwise, try to upgrade inclusiveDescendant. | ||
*/ | ||
this.dom.customElement.tryToUpgrade(inclusiveDescendant); | ||
} | ||
} | ||
@@ -353,4 +362,6 @@ } | ||
*/ | ||
if (!suppressObservers) { | ||
this.dom.observer.queueTreeMutationRecord(parent, nodes, [], previousSibling, child); | ||
if (util_1.globalStore.dom.features.mutationObservers) { | ||
if (!suppressObservers) { | ||
this.dom.observer.queueTreeMutationRecord(parent, nodes, [], previousSibling, child); | ||
} | ||
} | ||
@@ -374,3 +385,3 @@ } | ||
parent.nodeType !== interfaces_1.NodeType.Element) | ||
throw DOMException_1.DOMException.HierarchyRequestError; | ||
throw new DOMException_1.HierarchyRequestError(`Only document, document fragment and element nodes can contain child nodes. Parent node is ${parent.nodeName}.`); | ||
/** | ||
@@ -381,3 +392,3 @@ * 2. If node is a host-including inclusive ancestor of parent, throw a | ||
if (this.dom.tree.isAncestorOf(parent, node, true, true)) | ||
throw DOMException_1.DOMException.HierarchyRequestError; | ||
throw new DOMException_1.HierarchyRequestError(`The node to be inserted cannot be an ancestor of parent node. Node is ${node.nodeName}, parent node is ${parent.nodeName}.`); | ||
/** | ||
@@ -387,4 +398,4 @@ * 3. If child’s parent is not parent, then throw a "NotFoundError" | ||
*/ | ||
if (child.parentNode !== parent) | ||
throw DOMException_1.DOMException.NotFoundError; | ||
if (child._parent !== parent) | ||
throw new DOMException_1.NotFoundError(`The reference child node cannot be found under parent node. Child node is ${child.nodeName}, parent node is ${parent.nodeName}.`); | ||
/** | ||
@@ -402,3 +413,3 @@ * 4. If node is not a DocumentFragment, DocumentType, Element, Text, | ||
node.nodeType !== interfaces_1.NodeType.Comment) | ||
throw DOMException_1.DOMException.HierarchyRequestError; | ||
throw new DOMException_1.HierarchyRequestError(`Only document fragment, document type, element, text, processing instruction, cdata section or comment nodes can be inserted. Node is ${node.nodeName}.`); | ||
/** | ||
@@ -411,3 +422,6 @@ * 5. If either node is a Text node and parent is a document, or node is a | ||
parent.nodeType === interfaces_1.NodeType.Document) | ||
throw DOMException_1.DOMException.HierarchyRequestError; | ||
throw new DOMException_1.HierarchyRequestError(`Cannot insert a text node as a child of a document node. Node is ${node.nodeName}.`); | ||
if (node.nodeType === interfaces_1.NodeType.DocumentType && | ||
parent.nodeType !== interfaces_1.NodeType.Document) | ||
throw new DOMException_1.HierarchyRequestError(`A document type node can only be inserted under a document node. Parent node is ${parent.nodeName}.`); | ||
/** | ||
@@ -427,26 +441,24 @@ * 6. If parent is a document, and any of the statements below, switched on | ||
*/ | ||
if (node.nodeType === interfaces_1.NodeType.DocumentType && | ||
parent.nodeType !== interfaces_1.NodeType.Document) | ||
throw DOMException_1.DOMException.HierarchyRequestError; | ||
if (parent.nodeType === interfaces_1.NodeType.Document) { | ||
if (node.nodeType === interfaces_1.NodeType.DocumentFragment) { | ||
let eleCount = 0; | ||
for (const childNode of node.childNodes) { | ||
for (const childNode of node._children) { | ||
if (childNode.nodeType === interfaces_1.NodeType.Element) | ||
eleCount++; | ||
else if (childNode.nodeType === interfaces_1.NodeType.Text) | ||
throw DOMException_1.DOMException.HierarchyRequestError; | ||
if (eleCount > 1) | ||
throw DOMException_1.DOMException.HierarchyRequestError; | ||
throw new DOMException_1.HierarchyRequestError(`Cannot insert text a node as a child of a document node. Node is ${childNode.nodeName}.`); | ||
} | ||
if (eleCount === 1) { | ||
for (const ele of parent.childNodes) { | ||
if (eleCount > 1) { | ||
throw new DOMException_1.HierarchyRequestError(`A document node can only have one document element node. Document fragment to be inserted has ${eleCount} element nodes.`); | ||
} | ||
else if (eleCount === 1) { | ||
for (const ele of parent._children) { | ||
if (ele.nodeType === interfaces_1.NodeType.Element && ele !== child) | ||
throw DOMException_1.DOMException.HierarchyRequestError; | ||
throw new DOMException_1.HierarchyRequestError(`The document node already has a document element node.`); | ||
} | ||
let doctypeChild = child.nextSibling; | ||
let doctypeChild = child._nextSibling; | ||
while (doctypeChild) { | ||
if (doctypeChild.nodeType === interfaces_1.NodeType.DocumentType) | ||
throw DOMException_1.DOMException.HierarchyRequestError; | ||
doctypeChild = doctypeChild.nextSibling; | ||
throw new DOMException_1.HierarchyRequestError(`Cannot insert an element node before a document type node.`); | ||
doctypeChild = doctypeChild._nextSibling; | ||
} | ||
@@ -456,23 +468,23 @@ } | ||
else if (node.nodeType === interfaces_1.NodeType.Element) { | ||
for (const ele of parent.childNodes) { | ||
for (const ele of parent._children) { | ||
if (ele.nodeType === interfaces_1.NodeType.Element && ele !== child) | ||
throw DOMException_1.DOMException.HierarchyRequestError; | ||
throw new DOMException_1.HierarchyRequestError(`Document already has a document element node. Node is ${node.nodeName}.`); | ||
} | ||
let doctypeChild = child.nextSibling; | ||
let doctypeChild = child._nextSibling; | ||
while (doctypeChild) { | ||
if (doctypeChild.nodeType === interfaces_1.NodeType.DocumentType) | ||
throw DOMException_1.DOMException.HierarchyRequestError; | ||
doctypeChild = doctypeChild.nextSibling; | ||
throw new DOMException_1.HierarchyRequestError(`Cannot insert an element node before a document type node. Node is ${node.nodeName}.`); | ||
doctypeChild = doctypeChild._nextSibling; | ||
} | ||
} | ||
else if (node.nodeType === interfaces_1.NodeType.DocumentType) { | ||
for (const ele of parent.childNodes) { | ||
for (const ele of parent._children) { | ||
if (ele.nodeType === interfaces_1.NodeType.DocumentType && ele !== child) | ||
throw DOMException_1.DOMException.HierarchyRequestError; | ||
throw new DOMException_1.HierarchyRequestError(`Document already has a document type node. Node is ${node.nodeName}.`); | ||
} | ||
let elementChild = child.previousSibling; | ||
let elementChild = child._previousSibling; | ||
while (elementChild) { | ||
if (elementChild.nodeType === interfaces_1.NodeType.Element) | ||
throw DOMException_1.DOMException.HierarchyRequestError; | ||
elementChild = elementChild.previousSibling; | ||
throw new DOMException_1.HierarchyRequestError(`Cannot insert a document type node before an element node. Node is ${node.nodeName}.`); | ||
elementChild = elementChild._previousSibling; | ||
} | ||
@@ -486,6 +498,6 @@ } | ||
*/ | ||
let referenceChild = child.nextSibling; | ||
let referenceChild = child._nextSibling; | ||
if (referenceChild === node) | ||
referenceChild = node.nextSibling; | ||
let previousSibling = child.previousSibling; | ||
referenceChild = node._nextSibling; | ||
let previousSibling = child._previousSibling; | ||
/** | ||
@@ -500,3 +512,3 @@ * 10. Adopt node into parent’s node document. | ||
*/ | ||
if (child.parentNode !== null) { | ||
if (child._parent !== null) { | ||
/** | ||
@@ -508,3 +520,3 @@ * 12.1. Set removedNodes to [child]. | ||
removedNodes.push(child); | ||
this.remove(child, parent, true); | ||
this.remove(child, child._parent, true); | ||
} | ||
@@ -517,3 +529,3 @@ /** | ||
if (node.nodeType === interfaces_1.NodeType.DocumentFragment) { | ||
for (const childNode of node.childNodes) { | ||
for (const childNode of node._children) { | ||
nodes.push(childNode); | ||
@@ -534,3 +546,5 @@ } | ||
*/ | ||
this.dom.observer.queueTreeMutationRecord(parent, nodes, removedNodes, previousSibling, referenceChild); | ||
if (util_1.globalStore.dom.features.mutationObservers) { | ||
this.dom.observer.queueTreeMutationRecord(parent, nodes, removedNodes, previousSibling, referenceChild); | ||
} | ||
/** | ||
@@ -553,3 +567,3 @@ * 16. Return child. | ||
const removedNodes = []; | ||
for (const childNode of parent.childNodes) { | ||
for (const childNode of parent._children) { | ||
removedNodes.push(childNode); | ||
@@ -565,3 +579,3 @@ } | ||
if (node && node.nodeType === interfaces_1.NodeType.DocumentFragment) { | ||
for (const childNode of node.childNodes) { | ||
for (const childNode of node._children) { | ||
addedNodes.push(childNode); | ||
@@ -591,3 +605,5 @@ } | ||
*/ | ||
this.dom.observer.queueTreeMutationRecord(parent, addedNodes, removedNodes, null, null); | ||
if (util_1.globalStore.dom.features.mutationObservers) { | ||
this.dom.observer.queueTreeMutationRecord(parent, addedNodes, removedNodes, null, null); | ||
} | ||
} | ||
@@ -602,4 +618,4 @@ /** @inheritdoc */ | ||
*/ | ||
if (child.parentNode !== parent) | ||
throw DOMException_1.DOMException.NotFoundError; | ||
if (child._parent !== parent) | ||
throw new DOMException_1.NotFoundError(`The child node cannot be found under parent node. Child node is ${child.nodeName}, parent node is ${parent.nodeName}.`); | ||
this.remove(child, parent); | ||
@@ -610,41 +626,43 @@ return child; | ||
remove(node, parent, suppressObservers) { | ||
/** | ||
* 1. Let index be node’s index. | ||
*/ | ||
const index = this.dom.tree.index(node); | ||
/** | ||
* 2. For each live range whose start node is an inclusive descendant of | ||
* node, set its start to (parent, index). | ||
* 3. For each live range whose end node is an inclusive descendant of | ||
* node, set its end to (parent, index). | ||
*/ | ||
for (const range of this.dom.range.rangeList) { | ||
if (this.dom.tree.isDescendantOf(node, range._start[0], true)) { | ||
range._start = [parent, index]; | ||
if (this.dom.range.rangeList.length !== 0) { | ||
/** | ||
* 1. Let index be node’s index. | ||
*/ | ||
const index = this.dom.tree.index(node); | ||
/** | ||
* 2. For each live range whose start node is an inclusive descendant of | ||
* node, set its start to (parent, index). | ||
* 3. For each live range whose end node is an inclusive descendant of | ||
* node, set its end to (parent, index). | ||
*/ | ||
for (const range of this.dom.range.rangeList) { | ||
if (this.dom.tree.isDescendantOf(node, range._start[0], true)) { | ||
range._start = [parent, index]; | ||
} | ||
if (this.dom.tree.isDescendantOf(node, range._end[0], true)) { | ||
range._end = [parent, index]; | ||
} | ||
if (range._start[0] === parent && range._start[1] > index) { | ||
range._start[1]--; | ||
} | ||
if (range._end[0] === parent && range._end[1] > index) { | ||
range._end[1]--; | ||
} | ||
} | ||
if (this.dom.tree.isDescendantOf(node, range._end[0], true)) { | ||
range._end = [parent, index]; | ||
/** | ||
* 4. For each live range whose start node is parent and start offset is | ||
* greater than index, decrease its start offset by 1. | ||
* 5. For each live range whose end node is parent and end offset is greater | ||
* than index, decrease its end offset by 1. | ||
*/ | ||
for (const range of this.dom.range.rangeList) { | ||
if (range._start[0] === parent && range._start[1] > index) { | ||
range._start[1] -= 1; | ||
} | ||
if (range._end[0] === parent && range._end[1] > index) { | ||
range._end[1] -= 1; | ||
} | ||
} | ||
if (range._start[0] === parent && range._start[1] > index) { | ||
range._start[1]--; | ||
} | ||
if (range._end[0] === parent && range._end[1] > index) { | ||
range._end[1]--; | ||
} | ||
} | ||
/** | ||
* 4. For each live range whose start node is parent and start offset is | ||
* greater than index, decrease its start offset by 1. | ||
* 5. For each live range whose end node is parent and end offset is greater | ||
* than index, decrease its end offset by 1. | ||
*/ | ||
for (const range of this.dom.range.rangeList) { | ||
if (range._start[0] === parent && range._start[1] > index) { | ||
range._start[1] -= 1; | ||
} | ||
if (range._end[0] === parent && range._end[1] > index) { | ||
range._end[1] -= 1; | ||
} | ||
} | ||
/** | ||
* 6. For each NodeIterator object iterator whose root’s node document is | ||
@@ -663,4 +681,4 @@ * node’s node document, run the NodeIterator pre-removing steps given node | ||
*/ | ||
const oldPreviousSibling = node.previousSibling; | ||
const oldNextSibling = node.nextSibling; | ||
const oldPreviousSibling = node._previousSibling; | ||
const oldNextSibling = node._nextSibling; | ||
/** | ||
@@ -672,4 +690,4 @@ * 9. Remove node from its parent’s children. | ||
// assign siblings and children for quick lookups | ||
const prev = node.previousSibling; | ||
const next = node.nextSibling; | ||
const prev = node._previousSibling; | ||
const next = node._nextSibling; | ||
node._previousSibling = null; | ||
@@ -689,4 +707,6 @@ node._nextSibling = null; | ||
*/ | ||
if (util_1.Guard.isSlotable(node) && this.dom.shadowTree.isAssigned(node)) { | ||
this.dom.shadowTree.assignSlotables(node._assignedSlot); | ||
if (util_1.globalStore.dom.features.slots) { | ||
if (util_1.Guard.isSlotable(node) && node._assignedSlot !== null && this.dom.shadowTree.isAssigned(node)) { | ||
this.dom.shadowTree.assignSlotables(node._assignedSlot); | ||
} | ||
} | ||
@@ -698,5 +718,7 @@ /** | ||
*/ | ||
if (util_1.Guard.isShadowRoot(this.dom.tree.rootNode(parent)) && | ||
util_1.Guard.isSlot(parent) && util_2.isEmpty(parent._assignedNodes)) { | ||
this.dom.shadowTree.signalASlotChange(parent); | ||
if (util_1.globalStore.dom.features.slots) { | ||
if (util_1.Guard.isShadowRoot(this.dom.tree.rootNode(parent)) && | ||
util_1.Guard.isSlot(parent) && util_2.isEmpty(parent._assignedNodes)) { | ||
this.dom.shadowTree.signalASlotChange(parent); | ||
} | ||
} | ||
@@ -708,13 +730,15 @@ /** | ||
*/ | ||
let hasSlotDescendant = false; | ||
for (const descendant of this.dom.tree.getDescendantElements(node, true)) { | ||
if (util_1.Guard.isSlot(descendant)) { | ||
hasSlotDescendant = true; | ||
break; | ||
if (util_1.globalStore.dom.features.slots) { | ||
let hasSlotDescendant = false; | ||
for (const descendant of this.dom.tree.getDescendantElements(node, true)) { | ||
if (util_1.Guard.isSlot(descendant)) { | ||
hasSlotDescendant = true; | ||
break; | ||
} | ||
} | ||
if (hasSlotDescendant) { | ||
this.dom.shadowTree.assignSlotablesForATree(this.dom.tree.rootNode(parent)); | ||
this.dom.shadowTree.assignSlotablesForATree(node); | ||
} | ||
} | ||
if (hasSlotDescendant) { | ||
this.dom.shadowTree.assignSlotablesForATree(this.dom.tree.rootNode(parent)); | ||
this.dom.shadowTree.assignSlotablesForATree(node); | ||
} | ||
/** | ||
@@ -729,4 +753,6 @@ * 13. Run the removing steps with node and parent. | ||
*/ | ||
if (util_1.Guard.isCustomElementNode(node)) { | ||
this.dom.customElement.enqueueACustomElementCallbackReaction(node, "disconnectedCallback", []); | ||
if (util_1.globalStore.dom.features.customElements) { | ||
if (util_1.Guard.isCustomElementNode(node)) { | ||
this.dom.customElement.enqueueACustomElementCallbackReaction(node, "disconnectedCallback", []); | ||
} | ||
} | ||
@@ -747,4 +773,6 @@ /** | ||
*/ | ||
if (util_1.Guard.isCustomElementNode(descendant)) { | ||
this.dom.customElement.enqueueACustomElementCallbackReaction(descendant, "disconnectedCallback", []); | ||
if (util_1.globalStore.dom.features.customElements) { | ||
if (util_1.Guard.isCustomElementNode(descendant)) { | ||
this.dom.customElement.enqueueACustomElementCallbackReaction(descendant, "disconnectedCallback", []); | ||
} | ||
} | ||
@@ -761,10 +789,12 @@ } | ||
*/ | ||
for (const inclusiveAncestor of this.dom.tree.getAncestorNodes(parent, true)) { | ||
for (const registered of inclusiveAncestor._registeredObserverList) { | ||
if (registered.options.subtree) { | ||
node._registeredObserverList.push({ | ||
observer: registered.observer, | ||
options: registered.options, | ||
source: registered | ||
}); | ||
if (util_1.globalStore.dom.features.mutationObservers) { | ||
for (const inclusiveAncestor of this.dom.tree.getAncestorNodes(parent, true)) { | ||
for (const registered of inclusiveAncestor._registeredObserverList) { | ||
if (registered.options.subtree) { | ||
node._registeredObserverList.push({ | ||
observer: registered.observer, | ||
options: registered.options, | ||
source: registered | ||
}); | ||
} | ||
} | ||
@@ -778,4 +808,6 @@ } | ||
*/ | ||
if (!suppressObservers) { | ||
this.dom.observer.queueTreeMutationRecord(parent, [], [node], oldPreviousSibling, oldNextSibling); | ||
if (util_1.globalStore.dom.features.mutationObservers) { | ||
if (!suppressObservers) { | ||
this.dom.observer.queueTreeMutationRecord(parent, [], [node], oldPreviousSibling, oldNextSibling); | ||
} | ||
} | ||
@@ -782,0 +814,0 @@ /** |
@@ -26,3 +26,3 @@ "use strict"; | ||
*/ | ||
const window = util_1.globalStore.window; | ||
const window = util_1.globalStore.dom.window; | ||
if (window._mutationObserverMicrotaskQueued) | ||
@@ -41,3 +41,3 @@ return; | ||
*/ | ||
const window = util_1.globalStore.window; | ||
const window = util_1.globalStore.dom.window; | ||
window._mutationObserverMicrotaskQueued = false; | ||
@@ -50,4 +50,3 @@ const notifySet = infra_1.set.clone(window._mutationObservers); | ||
*/ | ||
for (const moItem of notifySet) { | ||
const mo = moItem; | ||
for (const mo of notifySet) { | ||
/** | ||
@@ -54,0 +53,0 @@ * 5.1. Let records be a clone of mo’s record queue. |
@@ -26,5 +26,5 @@ "use strict"; | ||
if (!this.dom.xml.isName(qualifiedName)) | ||
throw DOMException_1.DOMException.InvalidCharacterError; | ||
throw new DOMException_1.InvalidCharacterError(); | ||
if (!this.dom.xml.isQName(qualifiedName)) | ||
throw DOMException_1.DOMException.InvalidCharacterError; | ||
throw new DOMException_1.InvalidCharacterError(); | ||
} | ||
@@ -57,11 +57,11 @@ /** @inheritdoc */ | ||
if (prefix && namespace === null) | ||
throw DOMException_1.DOMException.NamespaceError; | ||
throw new DOMException_1.NamespaceError(); | ||
if (prefix === "xml" && namespace !== infra_1.namespace.XML) | ||
throw DOMException_1.DOMException.NamespaceError; | ||
throw new DOMException_1.NamespaceError(); | ||
if (namespace !== infra_1.namespace.XMLNS && | ||
(prefix === "xmlns" || qualifiedName === "xmlns")) | ||
throw DOMException_1.DOMException.NamespaceError; | ||
throw new DOMException_1.NamespaceError(); | ||
if (namespace === infra_1.namespace.XMLNS && | ||
(prefix !== "xmlns" && qualifiedName !== "xmlns")) | ||
throw DOMException_1.DOMException.NamespaceError; | ||
throw new DOMException_1.NamespaceError(); | ||
return [namespace, prefix, localName]; | ||
@@ -68,0 +68,0 @@ } |
@@ -138,3 +138,3 @@ "use strict"; | ||
if (cloneChildrenFlag) { | ||
for (const child of node.childNodes) { | ||
for (const child of node._children) { | ||
const childCopy = this.clone(child, document, true); | ||
@@ -202,8 +202,6 @@ this.dom.mutation.append(childCopy, copy); | ||
const attrMap = new Map(); | ||
for (const attr of a._attributeList) { | ||
const attrA = attr; | ||
for (const attrA of a._attributeList) { | ||
attrMap.set((attrA._namespace || '') + attrA._localName + attrA._value, attrA); | ||
} | ||
for (const attr of b._attributeList) { | ||
const attrB = attr; | ||
for (const attrB of b._attributeList) { | ||
const attrA = attrMap.get((attrB._namespace || '') + attrB._localName + attrB._value); | ||
@@ -220,11 +218,15 @@ if (!attrA) | ||
*/ | ||
if (a.childNodes.length !== b.childNodes.length) | ||
if (a._children.size !== b._children.size) | ||
return false; | ||
for (let i = 0; i < a.childNodes.length; i++) { | ||
const child1 = a.childNodes.item(i); | ||
const child2 = b.childNodes.item(i); | ||
if (child1 === null || child2 === null) | ||
return false; | ||
const itA = a._children[Symbol.iterator](); | ||
const itB = b._children[Symbol.iterator](); | ||
let resultA = itA.next(); | ||
let resultB = itB.next(); | ||
while (!resultA.done && !resultB.done) { | ||
const child1 = resultA.value; | ||
const child2 = resultB.value; | ||
if (!this.equals(child1, child2)) | ||
return false; | ||
resultA = itA.next(); | ||
resultB = itB.next(); | ||
} | ||
@@ -255,8 +257,11 @@ return true; | ||
ele._qualifiedName === qualifiedName.toLowerCase()) { | ||
return ele; | ||
return true; | ||
} | ||
else if (ele._namespace !== infra_1.namespace.HTML && | ||
ele._qualifiedName === qualifiedName) { | ||
return ele; | ||
return true; | ||
} | ||
else { | ||
return false; | ||
} | ||
}); | ||
@@ -266,5 +271,3 @@ } | ||
return this.dom.create.htmlCollection(root, function (ele) { | ||
if (ele._qualifiedName === qualifiedName) { | ||
return ele; | ||
} | ||
return (ele._qualifiedName === qualifiedName); | ||
}); | ||
@@ -296,5 +299,3 @@ } | ||
return this.dom.create.htmlCollection(root, function (ele) { | ||
if (ele._localName === localName) { | ||
return ele; | ||
} | ||
return (ele._localName === localName); | ||
}); | ||
@@ -304,5 +305,3 @@ } | ||
return this.dom.create.htmlCollection(root, function (ele) { | ||
if (ele._namespace === namespace) { | ||
return ele; | ||
} | ||
return (ele._namespace === namespace); | ||
}); | ||
@@ -312,5 +311,3 @@ } | ||
return this.dom.create.htmlCollection(root, function (ele) { | ||
if (ele._localName === localName && ele._namespace === namespace) { | ||
return ele; | ||
} | ||
return (ele._localName === localName && ele._namespace === namespace); | ||
}); | ||
@@ -357,5 +354,4 @@ } | ||
for (const attr of element._attributeList) { | ||
const attrInt = attr; | ||
if (attrInt._namespacePrefix === "xmlns" && attrInt._value === namespace) { | ||
return attrInt._localName; | ||
if (attr._namespacePrefix === "xmlns" && attr._value === namespace) { | ||
return attr._localName; | ||
} | ||
@@ -393,11 +389,10 @@ } | ||
for (const attr of node._attributeList) { | ||
const attrInt = attr; | ||
if (attrInt._namespace === infra_1.namespace.XMLNS && | ||
attrInt._namespacePrefix === "xmlns" && | ||
attrInt._localName === prefix) { | ||
return attrInt._value || null; | ||
if (attr._namespace === infra_1.namespace.XMLNS && | ||
attr._namespacePrefix === "xmlns" && | ||
attr._localName === prefix) { | ||
return attr._value || null; | ||
} | ||
if (prefix === null && attrInt._namespace === infra_1.namespace.XMLNS && | ||
attrInt._namespacePrefix === null && attrInt._localName === "xmlns") { | ||
return attrInt._value || null; | ||
if (prefix === null && attr._namespace === infra_1.namespace.XMLNS && | ||
attr._namespacePrefix === null && attr._localName === "xmlns") { | ||
return attr._value || null; | ||
} | ||
@@ -404,0 +399,0 @@ } |
@@ -103,3 +103,3 @@ "use strict"; | ||
get iteratorList() { | ||
return util_1.globalStore.window._iteratorList; | ||
return util_1.globalStore.dom.window._iteratorList; | ||
} | ||
@@ -106,0 +106,0 @@ } |
@@ -36,7 +36,7 @@ import { DOMAlgorithm, RangeAlgorithm } from './interfaces'; | ||
/** @inheritdoc */ | ||
getContainedNodes(range: Range): IterableIterator<Node>; | ||
getContainedNodes(range: Range): Iterable<Node>; | ||
/** @inheritdoc */ | ||
getPartiallyContainedNodes(range: Range): IterableIterator<Node>; | ||
getPartiallyContainedNodes(range: Range): Iterable<Node>; | ||
/** @inheritdoc */ | ||
get rangeList(): ObjectCache<Range>; | ||
} |
@@ -67,7 +67,7 @@ "use strict"; | ||
*/ | ||
if (util_1.Guard.isDocumentTypeNode(node.nodeType)) { | ||
throw DOMException_1.DOMException.InvalidNodeTypeError; | ||
if (util_1.Guard.isDocumentTypeNode(node)) { | ||
throw new DOMException_1.InvalidNodeTypeError(); | ||
} | ||
if (offset > this.dom.tree.nodeLength(node)) { | ||
throw DOMException_1.DOMException.IndexSizeError; | ||
throw new DOMException_1.IndexSizeError(); | ||
} | ||
@@ -93,7 +93,7 @@ const bp = [node, offset]; | ||
*/ | ||
if (util_1.Guard.isDocumentTypeNode(node.nodeType)) { | ||
throw DOMException_1.DOMException.InvalidNodeTypeError; | ||
if (util_1.Guard.isDocumentTypeNode(node)) { | ||
throw new DOMException_1.InvalidNodeTypeError(); | ||
} | ||
if (offset > this.dom.tree.nodeLength(node)) { | ||
throw DOMException_1.DOMException.IndexSizeError; | ||
throw new DOMException_1.IndexSizeError(); | ||
} | ||
@@ -115,3 +115,3 @@ const bp = [node, offset]; | ||
if (parent === null) | ||
throw DOMException_1.DOMException.InvalidNodeTypeError; | ||
throw new DOMException_1.InvalidNodeTypeError(); | ||
/** | ||
@@ -220,3 +220,3 @@ * 3. Let index be node’s index. | ||
if (util_1.Guard.isDocumentTypeNode(child)) { | ||
throw DOMException_1.DOMException.HierarchyRequestError; | ||
throw new DOMException_1.HierarchyRequestError(); | ||
} | ||
@@ -435,3 +435,3 @@ containedChildren.push(child); | ||
if (util_1.Guard.isDocumentTypeNode(child)) { | ||
throw DOMException_1.DOMException.HierarchyRequestError; | ||
throw new DOMException_1.HierarchyRequestError(); | ||
} | ||
@@ -530,3 +530,3 @@ containedChildren.push(child); | ||
range._startNode === node) { | ||
throw DOMException_1.DOMException.HierarchyRequestError; | ||
throw new DOMException_1.HierarchyRequestError(); | ||
} | ||
@@ -583,3 +583,3 @@ /** | ||
if (node === referenceNode) { | ||
referenceNode = node.nextSibling; | ||
referenceNode = node._nextSibling; | ||
} | ||
@@ -620,20 +620,54 @@ /** | ||
/** @inheritdoc */ | ||
*getContainedNodes(range) { | ||
const container = range.commonAncestorContainer; | ||
for (const node of this.dom.tree.getDescendantNodes(container)) { | ||
if (this.isContained(node, range)) | ||
yield node; | ||
} | ||
getContainedNodes(range) { | ||
return { | ||
[Symbol.iterator]: function () { | ||
const container = range.commonAncestorContainer; | ||
const it = this.dom.tree.getDescendantNodes(container)[Symbol.iterator](); | ||
let currentNode = it.next().value; | ||
return { | ||
next: function () { | ||
while (currentNode && !this.isContained(currentNode, range)) { | ||
currentNode = it.next().value; | ||
} | ||
if (currentNode === null) { | ||
return { done: true, value: null }; | ||
} | ||
else { | ||
const result = { done: false, value: currentNode }; | ||
currentNode = it.next().value; | ||
return result; | ||
} | ||
}.bind(this) | ||
}; | ||
}.bind(this) | ||
}; | ||
} | ||
/** @inheritdoc */ | ||
*getPartiallyContainedNodes(range) { | ||
const container = range.commonAncestorContainer; | ||
for (const node of this.dom.tree.getDescendantNodes(container)) { | ||
if (this.isPartiallyContained(node, range)) | ||
yield node; | ||
} | ||
getPartiallyContainedNodes(range) { | ||
return { | ||
[Symbol.iterator]: function () { | ||
const container = range.commonAncestorContainer; | ||
const it = this.dom.tree.getDescendantNodes(container)[Symbol.iterator](); | ||
let currentNode = it.next().value; | ||
return { | ||
next: function () { | ||
while (currentNode && !this.isPartiallyContained(currentNode, range)) { | ||
currentNode = it.next().value; | ||
} | ||
if (currentNode === null) { | ||
return { done: true, value: null }; | ||
} | ||
else { | ||
const result = { done: false, value: currentNode }; | ||
currentNode = it.next().value; | ||
return result; | ||
} | ||
}.bind(this) | ||
}; | ||
}.bind(this) | ||
}; | ||
} | ||
/** @inheritdoc */ | ||
get rangeList() { | ||
return util_1.globalStore.window._rangeList; | ||
return util_1.globalStore.dom.window._rangeList; | ||
} | ||
@@ -640,0 +674,0 @@ } |
@@ -26,3 +26,3 @@ "use strict"; | ||
*/ | ||
throw DOMException_1.DOMException.NotSupportedError; | ||
throw new DOMException_1.NotSupportedError(); | ||
} | ||
@@ -29,0 +29,0 @@ } |
@@ -75,3 +75,3 @@ "use strict"; | ||
const host = root._host; | ||
for (const slotable of host.childNodes) { | ||
for (const slotable of host._children) { | ||
if (util_1.Guard.isSlotable(slotable)) { | ||
@@ -110,3 +110,3 @@ /** | ||
if (util_2.isEmpty(slotables)) { | ||
for (const slotable of slot.childNodes) { | ||
for (const slotable of slot._children) { | ||
if (util_1.Guard.isSlotable(slotable)) { | ||
@@ -179,6 +179,4 @@ slotables.push(slotable); | ||
*/ | ||
for (const slot of this.dom.tree.getDescendantNodes(root, true)) { | ||
if (util_1.Guard.isSlot(slot)) { | ||
this.assignSlotables(slot); | ||
} | ||
for (const slot of this.dom.tree.getDescendantNodes(root, true, false, (e) => util_1.Guard.isSlot(e))) { | ||
this.assignSlotables(slot); | ||
} | ||
@@ -203,3 +201,3 @@ } | ||
*/ | ||
const window = util_1.globalStore.window; | ||
const window = util_1.globalStore.dom.window; | ||
window._signalSlots.add(slot); | ||
@@ -206,0 +204,0 @@ this.dom.observer.queueAMutationObserverMicrotask(); |
@@ -15,5 +15,5 @@ import { DOMAlgorithm, TextAlgorithm } from './interfaces'; | ||
/** @inheritdoc */ | ||
contiguousTextNodes(node: Text, self?: boolean): IterableIterator<Text>; | ||
contiguousTextNodes(node: Text, self?: boolean): Iterable<Text>; | ||
/** @inheritdoc */ | ||
contiguousExclusiveTextNodes(node: Text, self?: boolean): IterableIterator<Text>; | ||
contiguousExclusiveTextNodes(node: Text, self?: boolean): Iterable<Text>; | ||
/** @inheritdoc */ | ||
@@ -20,0 +20,0 @@ descendantTextContent(node: Node): string; |
@@ -19,3 +19,3 @@ "use strict"; | ||
/** @inheritdoc */ | ||
*contiguousTextNodes(node, self = false) { | ||
contiguousTextNodes(node, self = false) { | ||
/** | ||
@@ -27,24 +27,38 @@ * The contiguous Text nodes of a node node are node, node’s previous | ||
*/ | ||
let sibling = node; | ||
while (sibling._previousSibling !== null && util_1.Guard.isTextNode(sibling._previousSibling)) { | ||
sibling = sibling._previousSibling; | ||
} | ||
while (true) { | ||
if (sibling === node) { | ||
if (self) | ||
yield sibling; | ||
return { | ||
[Symbol.iterator]() { | ||
let currentNode = node; | ||
while (currentNode && util_1.Guard.isTextNode(currentNode._previousSibling)) { | ||
currentNode = currentNode._previousSibling; | ||
} | ||
return { | ||
next() { | ||
if (currentNode && (!self && currentNode === node)) { | ||
if (util_1.Guard.isTextNode(currentNode._nextSibling)) { | ||
currentNode = currentNode._nextSibling; | ||
} | ||
else { | ||
currentNode = null; | ||
} | ||
} | ||
if (currentNode === null) { | ||
return { done: true, value: null }; | ||
} | ||
else { | ||
const result = { done: false, value: currentNode }; | ||
if (util_1.Guard.isTextNode(currentNode._nextSibling)) { | ||
currentNode = currentNode._nextSibling; | ||
} | ||
else { | ||
currentNode = null; | ||
} | ||
return result; | ||
} | ||
} | ||
}; | ||
} | ||
else { | ||
yield sibling; | ||
} | ||
if (sibling._nextSibling !== null && util_1.Guard.isTextNode(sibling._nextSibling)) { | ||
sibling = sibling._nextSibling; | ||
} | ||
else { | ||
break; | ||
} | ||
} | ||
}; | ||
} | ||
/** @inheritdoc */ | ||
*contiguousExclusiveTextNodes(node, self = false) { | ||
contiguousExclusiveTextNodes(node, self = false) { | ||
/** | ||
@@ -56,21 +70,35 @@ * The contiguous exclusive Text nodes of a node node are node, node’s | ||
*/ | ||
let sibling = node; | ||
while (sibling._previousSibling !== null && util_1.Guard.isExclusiveTextNode(sibling._previousSibling)) { | ||
sibling = sibling._previousSibling; | ||
} | ||
while (true) { | ||
if (sibling === node) { | ||
if (self) | ||
yield sibling; | ||
return { | ||
[Symbol.iterator]() { | ||
let currentNode = node; | ||
while (currentNode && util_1.Guard.isExclusiveTextNode(currentNode._previousSibling)) { | ||
currentNode = currentNode._previousSibling; | ||
} | ||
return { | ||
next() { | ||
if (currentNode && (!self && currentNode === node)) { | ||
if (util_1.Guard.isExclusiveTextNode(currentNode._nextSibling)) { | ||
currentNode = currentNode._nextSibling; | ||
} | ||
else { | ||
currentNode = null; | ||
} | ||
} | ||
if (currentNode === null) { | ||
return { done: true, value: null }; | ||
} | ||
else { | ||
const result = { done: false, value: currentNode }; | ||
if (util_1.Guard.isExclusiveTextNode(currentNode._nextSibling)) { | ||
currentNode = currentNode._nextSibling; | ||
} | ||
else { | ||
currentNode = null; | ||
} | ||
return result; | ||
} | ||
} | ||
}; | ||
} | ||
else { | ||
yield sibling; | ||
} | ||
if (sibling._nextSibling !== null && util_1.Guard.isExclusiveTextNode(sibling._nextSibling)) { | ||
sibling = sibling._nextSibling; | ||
} | ||
else { | ||
break; | ||
} | ||
} | ||
}; | ||
} | ||
@@ -100,3 +128,3 @@ /** @inheritdoc */ | ||
if (offset > length) { | ||
throw DOMException_1.DOMException.IndexSizeError; | ||
throw new DOMException_1.IndexSizeError(); | ||
} | ||
@@ -115,3 +143,3 @@ /** | ||
const newNode = this.dom.create.text(node._nodeDocument, newData); | ||
const parent = node.parentNode; | ||
const parent = node._parent; | ||
if (parent !== null) { | ||
@@ -121,3 +149,3 @@ /** | ||
*/ | ||
this.dom.mutation.insert(newNode, parent, node.nextSibling); | ||
this.dom.mutation.insert(newNode, parent, node._nextSibling); | ||
/** | ||
@@ -124,0 +152,0 @@ * 7.2. For each live range whose start node is node and start offset is |
@@ -25,3 +25,3 @@ "use strict"; | ||
if (traverser._activeFlag) { | ||
throw DOMException_1.DOMException.InvalidStateError; | ||
throw new DOMException_1.InvalidStateError(); | ||
} | ||
@@ -28,0 +28,0 @@ /** |
@@ -14,10 +14,11 @@ import { TreeAlgorithm, DOMAlgorithm } from './interfaces'; | ||
constructor(algorithm: DOMAlgorithm); | ||
private _getNextDescendantNode; | ||
/** @inheritdoc */ | ||
getDescendantNodes(node: Node, self?: boolean, shadow?: boolean, filter?: ((childNode: Node) => any)): IterableIterator<Node>; | ||
getDescendantNodes(node: Node, self?: boolean, shadow?: boolean, filter?: ((childNode: Node) => boolean)): Iterable<Node>; | ||
/** @inheritdoc */ | ||
getDescendantElements(node: Node, self?: boolean, shadow?: boolean, filter?: ((childNode: Element) => any)): IterableIterator<Element>; | ||
getDescendantElements(node: Node, self?: boolean, shadow?: boolean, filter?: ((childNode: Element) => boolean)): Iterable<Element>; | ||
/** @inheritdoc */ | ||
getSiblingNodes(node: Node, self?: boolean, filter?: ((childNode: Node) => any)): IterableIterator<Node>; | ||
getSiblingNodes(node: Node, self?: boolean, filter?: ((childNode: Node) => boolean)): Iterable<Node>; | ||
/** @inheritdoc */ | ||
getAncestorNodes(node: Node, self?: boolean, filter?: ((ancestorNode: Node) => any)): IterableIterator<Node>; | ||
getAncestorNodes(node: Node, self?: boolean, filter?: ((ancestorNode: Node) => boolean)): Iterable<Node>; | ||
/** @inheritdoc */ | ||
@@ -24,0 +25,0 @@ getCommonAncestor(nodeA: Node, nodeB: Node): Node | null; |
@@ -18,61 +18,117 @@ "use strict"; | ||
} | ||
/** @inheritdoc */ | ||
*getDescendantNodes(node, self = false, shadow = false, filter = () => true) { | ||
if (self && filter(node)) | ||
yield node; | ||
_getNextDescendantNode(root, node, shadow = false) { | ||
// traverse shadow tree | ||
if (shadow && util_1.Guard.isElementNode(node)) { | ||
if (node.shadowRoot) { | ||
const shadowRoot = node.shadowRoot; | ||
let child = shadowRoot._firstChild; | ||
while (child) { | ||
yield* this.getDescendantNodes(child, true, shadow, filter); | ||
child = child._nextSibling; | ||
} | ||
} | ||
if (shadow && util_1.Guard.isElementNode(node) && util_1.Guard.isShadowRoot(node.shadowRoot)) { | ||
if (node.shadowRoot._firstChild) | ||
return node.shadowRoot._firstChild; | ||
} | ||
// traverse child nodes | ||
let child = node._firstChild; | ||
while (child) { | ||
yield* this.getDescendantNodes(child, true, shadow, filter); | ||
child = child._nextSibling; | ||
if (node._firstChild) | ||
return node._firstChild; | ||
if (node === root) | ||
return null; | ||
// traverse siblings | ||
if (node._nextSibling) | ||
return node._nextSibling; | ||
// traverse parent's next sibling | ||
let parent = node._parent; | ||
while (parent && parent !== root) { | ||
if (parent._nextSibling) | ||
return parent._nextSibling; | ||
parent = parent._parent; | ||
} | ||
return null; | ||
} | ||
/** @inheritdoc */ | ||
*getDescendantElements(node, self = false, shadow = false, filter = (() => true)) { | ||
for (const child of this.getDescendantNodes(node, self, shadow, (node) => { return util_1.Guard.isElementNode(node); })) { | ||
const ele = child; | ||
if (filter(ele)) | ||
yield ele; | ||
} | ||
getDescendantNodes(node, self = false, shadow = false, filter) { | ||
return { | ||
[Symbol.iterator]: function () { | ||
let currentNode = (self ? node : this._getNextDescendantNode(node, node, shadow)); | ||
return { | ||
next: function () { | ||
while (currentNode && filter && !filter(currentNode)) { | ||
currentNode = this._getNextDescendantNode(node, currentNode, shadow); | ||
} | ||
if (currentNode === null) { | ||
return { done: true, value: null }; | ||
} | ||
else { | ||
const result = { done: false, value: currentNode }; | ||
currentNode = this._getNextDescendantNode(node, currentNode, shadow); | ||
return result; | ||
} | ||
}.bind(this) | ||
}; | ||
}.bind(this) | ||
}; | ||
} | ||
/** @inheritdoc */ | ||
*getSiblingNodes(node, self = false, filter = (() => true)) { | ||
if (node._parent) { | ||
const parent = node._parent; | ||
let child = parent._firstChild; | ||
while (child) { | ||
if (!filter || !!filter(child)) { | ||
if (child === node) { | ||
if (self) | ||
yield child; | ||
getDescendantElements(node, self = false, shadow = false, filter) { | ||
return { | ||
[Symbol.iterator]: function () { | ||
const it = this.getDescendantNodes(node, self, shadow, (e) => util_1.Guard.isElementNode(e))[Symbol.iterator](); | ||
let currentNode = it.next().value; | ||
return { | ||
next() { | ||
while (currentNode && filter && !filter(currentNode)) { | ||
currentNode = it.next().value; | ||
} | ||
if (currentNode === null) { | ||
return { done: true, value: null }; | ||
} | ||
else { | ||
const result = { done: false, value: currentNode }; | ||
currentNode = it.next().value; | ||
return result; | ||
} | ||
} | ||
else { | ||
yield child; | ||
}; | ||
}.bind(this) | ||
}; | ||
} | ||
/** @inheritdoc */ | ||
getSiblingNodes(node, self = false, filter) { | ||
return { | ||
[Symbol.iterator]() { | ||
let currentNode = node._parent ? node._parent._firstChild : null; | ||
return { | ||
next() { | ||
while (currentNode && (filter && !filter(currentNode) || (!self && currentNode === node))) { | ||
currentNode = currentNode._nextSibling; | ||
} | ||
if (currentNode === null) { | ||
return { done: true, value: null }; | ||
} | ||
else { | ||
const result = { done: false, value: currentNode }; | ||
currentNode = currentNode._nextSibling; | ||
return result; | ||
} | ||
} | ||
} | ||
child = child._nextSibling; | ||
}; | ||
} | ||
} | ||
}; | ||
} | ||
/** @inheritdoc */ | ||
*getAncestorNodes(node, self = false, filter = (() => true)) { | ||
if (self && filter(node)) | ||
yield node; | ||
let parent = node._parent; | ||
while (parent !== null) { | ||
if (filter(parent)) | ||
yield parent; | ||
parent = parent._parent; | ||
} | ||
getAncestorNodes(node, self = false, filter) { | ||
return { | ||
[Symbol.iterator]() { | ||
let currentNode = self ? node : node._parent; | ||
return { | ||
next() { | ||
while (currentNode && (filter && !filter(currentNode))) { | ||
currentNode = currentNode._parent; | ||
} | ||
if (currentNode === null) { | ||
return { done: true, value: null }; | ||
} | ||
else { | ||
const result = { done: false, value: currentNode }; | ||
currentNode = currentNode._parent; | ||
return result; | ||
} | ||
} | ||
}; | ||
} | ||
}; | ||
} | ||
@@ -148,3 +204,3 @@ /** @inheritdoc */ | ||
let hasElement = false; | ||
for (const childNode of node.childNodes) { | ||
for (const childNode of node._children) { | ||
switch (childNode.nodeType) { | ||
@@ -171,3 +227,3 @@ case interfaces_1.NodeType.ProcessingInstruction: | ||
case interfaces_1.NodeType.Element: | ||
for (const childNode of node.childNodes) { | ||
for (const childNode of node._children) { | ||
switch (childNode.nodeType) { | ||
@@ -174,0 +230,0 @@ case interfaces_1.NodeType.Element: |
@@ -25,3 +25,3 @@ "use strict"; | ||
*/ | ||
let node = (first ? walker._current.firstChild : walker._current.lastChild); | ||
let node = (first ? walker._current._firstChild : walker._current._lastChild); | ||
while (node !== null) { | ||
@@ -47,3 +47,3 @@ /** | ||
*/ | ||
const child = (first ? node.firstChild : node.lastChild); | ||
const child = (first ? node._firstChild : node._lastChild); | ||
if (child !== null) { | ||
@@ -63,3 +63,3 @@ node = child; | ||
*/ | ||
const sibling = (first ? node.nextSibling : node.previousSibling); | ||
const sibling = (first ? node._nextSibling : node._previousSibling); | ||
if (sibling !== null) { | ||
@@ -74,3 +74,3 @@ node = sibling; | ||
*/ | ||
const parent = node.parentNode; | ||
const parent = node._parent; | ||
if (parent === null || parent === walker._root || parent === walker._current) { | ||
@@ -106,3 +106,3 @@ return null; | ||
*/ | ||
let sibling = (next ? node.nextSibling : node.previousSibling); | ||
let sibling = (next ? node._nextSibling : node._previousSibling); | ||
while (sibling) { | ||
@@ -128,5 +128,5 @@ /** | ||
*/ | ||
sibling = (next ? node.firstChild : node.lastChild); | ||
sibling = (next ? node._firstChild : node._lastChild); | ||
if (result === interfaces_1.FilterResult.Reject || sibling === null) { | ||
sibling = (next ? node.nextSibling : node.previousSibling); | ||
sibling = (next ? node._nextSibling : node._previousSibling); | ||
} | ||
@@ -138,6 +138,9 @@ } | ||
*/ | ||
node = node.parentNode; | ||
if (node === null || node === walker._root) { | ||
if (node._parent === null) { | ||
return null; | ||
} | ||
node = node._parent; | ||
if (node === walker._root) { | ||
return null; | ||
} | ||
/** | ||
@@ -144,0 +147,0 @@ * 3.5. If the return value of filtering node within walker is FILTER_ACCEPT, |
@@ -18,7 +18,7 @@ "use strict"; | ||
isName(name) { | ||
return (!!name.match(XMLAlgorithmImpl.Name)); | ||
return XMLAlgorithmImpl.Name.test(name); | ||
} | ||
/** @inheritdoc */ | ||
isQName(name) { | ||
return (!!name.match(XMLAlgorithmImpl.QName)); | ||
return XMLAlgorithmImpl.QName.test(name); | ||
} | ||
@@ -28,6 +28,6 @@ /** @inheritdoc */ | ||
if (xmlVersion === "1.0") { | ||
return (!chars.match(XMLAlgorithmImpl.InvalidChar_10)); | ||
return (!XMLAlgorithmImpl.InvalidChar_10.test(chars)); | ||
} | ||
else { | ||
return (!chars.match(XMLAlgorithmImpl.InvalidChar_11)); | ||
return (!XMLAlgorithmImpl.InvalidChar_11.test(chars)); | ||
} | ||
@@ -37,3 +37,3 @@ } | ||
isPubidChar(chars) { | ||
return (!!chars.match(XMLAlgorithmImpl.PubidChar)); | ||
return XMLAlgorithmImpl.PubidChar.test(chars); | ||
} | ||
@@ -40,0 +40,0 @@ } |
@@ -17,3 +17,3 @@ "use strict"; | ||
*/ | ||
this._algo = util_1.globalStore.algorithm; | ||
this._algo = util_1.globalStore.dom.algorithm; | ||
this._signal = this._algo.create.abortSignal(); | ||
@@ -20,0 +20,0 @@ } |
@@ -16,5 +16,5 @@ "use strict"; | ||
*/ | ||
const algo = util_1.globalStore.algorithm; | ||
const algo = util_1.globalStore.dom.algorithm; | ||
const context = util_1.Cast.asNode(this); | ||
const parent = context.parentNode; | ||
const parent = context._parent; | ||
if (parent === null) | ||
@@ -26,3 +26,3 @@ return; | ||
*/ | ||
let viablePreviousSibling = context.previousSibling; | ||
let viablePreviousSibling = context._previousSibling; | ||
let flag = true; | ||
@@ -33,3 +33,3 @@ while (flag && viablePreviousSibling) { | ||
if (child === viablePreviousSibling) { | ||
viablePreviousSibling = viablePreviousSibling.previousSibling; | ||
viablePreviousSibling = viablePreviousSibling._previousSibling; | ||
flag = true; | ||
@@ -50,5 +50,5 @@ break; | ||
if (viablePreviousSibling === null) | ||
viablePreviousSibling = parent.firstChild; | ||
viablePreviousSibling = parent._firstChild; | ||
else | ||
viablePreviousSibling = viablePreviousSibling.nextSibling; | ||
viablePreviousSibling = viablePreviousSibling._nextSibling; | ||
/** | ||
@@ -65,3 +65,3 @@ * 6. Pre-insert node into parent before viablePreviousSibling. | ||
*/ | ||
const algo = util_1.globalStore.algorithm; | ||
const algo = util_1.globalStore.dom.algorithm; | ||
const context = util_1.Cast.asNode(this); | ||
@@ -75,3 +75,3 @@ const parent = context.parentNode; | ||
*/ | ||
let viableNextSibling = context.nextSibling; | ||
let viableNextSibling = context._nextSibling; | ||
let flag = true; | ||
@@ -82,3 +82,3 @@ while (flag && viableNextSibling) { | ||
if (child === viableNextSibling) { | ||
viableNextSibling = viableNextSibling.nextSibling; | ||
viableNextSibling = viableNextSibling._nextSibling; | ||
flag = true; | ||
@@ -105,5 +105,5 @@ break; | ||
*/ | ||
const algo = util_1.globalStore.algorithm; | ||
const algo = util_1.globalStore.dom.algorithm; | ||
const context = util_1.Cast.asNode(this); | ||
const parent = context.parentNode; | ||
const parent = context._parent; | ||
if (!parent) | ||
@@ -115,3 +115,3 @@ return; | ||
*/ | ||
let viableNextSibling = context.nextSibling; | ||
let viableNextSibling = context._nextSibling; | ||
let flag = true; | ||
@@ -122,3 +122,3 @@ while (flag && viableNextSibling) { | ||
if (child === viableNextSibling) { | ||
viableNextSibling = viableNextSibling.nextSibling; | ||
viableNextSibling = viableNextSibling._nextSibling; | ||
flag = true; | ||
@@ -140,3 +140,3 @@ break; | ||
*/ | ||
if (context.parentNode === parent) | ||
if (context._parent === parent) | ||
algo.mutation.replace(context, node, parent); | ||
@@ -152,5 +152,5 @@ else | ||
*/ | ||
const algo = util_1.globalStore.algorithm; | ||
const algo = util_1.globalStore.dom.algorithm; | ||
const context = util_1.Cast.asNode(this); | ||
const parent = context.parentNode; | ||
const parent = context._parent; | ||
if (!parent) | ||
@@ -157,0 +157,0 @@ return; |
@@ -25,2 +25,14 @@ "use strict"; | ||
this._contentType = 'application/xml'; | ||
this._URL = { | ||
scheme: "about", | ||
username: "", | ||
password: "", | ||
host: null, | ||
port: null, | ||
path: ["blank"], | ||
query: null, | ||
fragment: null, | ||
_cannotBeABaseURLFlag: true, | ||
_blobURLEntry: null | ||
}; | ||
this._origin = null; | ||
@@ -31,3 +43,2 @@ this._type = "xml"; | ||
this._implementation = this._algo.create.domImplementation(this); | ||
this._URL = this._algo.create.urlRecord('about:blank'); | ||
} | ||
@@ -93,3 +104,3 @@ get _nodeDocument() { return this._nodeDocumentOverwrite || this; } | ||
*/ | ||
for (const child of this.childNodes) { | ||
for (const child of this._children) { | ||
if (util_1.Guard.isDocumentTypeNode(child)) | ||
@@ -105,3 +116,3 @@ return child; | ||
*/ | ||
for (const child of this.childNodes) { | ||
for (const child of this._children) { | ||
if (util_1.Guard.isElementNode(child)) | ||
@@ -155,3 +166,3 @@ return child; | ||
if (!this._algo.xml.isName(localName)) | ||
throw DOMException_1.DOMException.InvalidCharacterError; | ||
throw new DOMException_1.InvalidCharacterError(); | ||
if (this._type === "html") | ||
@@ -208,5 +219,5 @@ localName = localName.toLowerCase(); | ||
if (this._type === "html") | ||
throw DOMException_1.DOMException.NotSupportedError; | ||
throw new DOMException_1.NotSupportedError(); | ||
if (data.includes(']]>')) | ||
throw DOMException_1.DOMException.InvalidCharacterError; | ||
throw new DOMException_1.InvalidCharacterError(); | ||
return this._algo.create.cdataSection(this, data); | ||
@@ -233,5 +244,5 @@ } | ||
if (!this._algo.xml.isName(target)) | ||
throw DOMException_1.DOMException.InvalidCharacterError; | ||
throw new DOMException_1.InvalidCharacterError(); | ||
if (data.includes("?>")) | ||
throw DOMException_1.DOMException.InvalidCharacterError; | ||
throw new DOMException_1.InvalidCharacterError(); | ||
return this._algo.create.processingInstruction(this, target, data); | ||
@@ -245,3 +256,3 @@ } | ||
if (util_1.Guard.isDocumentNode(node) || util_1.Guard.isShadowRoot(node)) | ||
throw DOMException_1.DOMException.NotSupportedError; | ||
throw new DOMException_1.NotSupportedError(); | ||
/** | ||
@@ -258,3 +269,3 @@ * 2. Return a clone of node, with context object and the clone children flag set if deep is true. | ||
if (util_1.Guard.isDocumentNode(node)) | ||
throw DOMException_1.DOMException.NotSupportedError; | ||
throw new DOMException_1.NotSupportedError(); | ||
/** | ||
@@ -264,3 +275,3 @@ * 2. If node is a shadow root, then throw a "HierarchyRequestError" DOMException. | ||
if (util_1.Guard.isShadowRoot(node)) | ||
throw DOMException_1.DOMException.HierarchyRequestError; | ||
throw new DOMException_1.HierarchyRequestError(); | ||
/** | ||
@@ -284,3 +295,3 @@ * 3. Adopt node into the context object. | ||
if (!this._algo.xml.isName(localName)) | ||
throw DOMException_1.DOMException.InvalidCharacterError; | ||
throw new DOMException_1.InvalidCharacterError(); | ||
if (this._type === "html") { | ||
@@ -379,3 +390,3 @@ localName = localName.toLowerCase(); | ||
else { | ||
return util_1.globalStore["window"]; | ||
return util_1.globalStore.dom.window; | ||
} | ||
@@ -382,0 +393,0 @@ } |
@@ -15,29 +15,159 @@ /** | ||
*/ | ||
constructor(name: string, message: string); | ||
static IndexSizeError: DOMException; | ||
static DOMStringSizeError: DOMException; | ||
static HierarchyRequestError: DOMException; | ||
static WrongDocumentError: DOMException; | ||
static InvalidCharacterError: DOMException; | ||
static NoDataAllowedError: DOMException; | ||
static NoModificationAllowedError: DOMException; | ||
static NotFoundError: DOMException; | ||
static NotSupportedError: DOMException; | ||
static InUseAttributeError: DOMException; | ||
static InvalidStateError: DOMException; | ||
static SyntaxError: DOMException; | ||
static InvalidModificationError: DOMException; | ||
static NamespaceError: DOMException; | ||
static InvalidAccessError: DOMException; | ||
static ValidationError: DOMException; | ||
static TypeMismatchError: DOMException; | ||
static SecurityError: DOMException; | ||
static NetworkError: DOMException; | ||
static AbortError: DOMException; | ||
static URLMismatchError: DOMException; | ||
static QuotaExceededError: DOMException; | ||
static TimeoutError: DOMException; | ||
static InvalidNodeTypeError: DOMException; | ||
static DataCloneError: DOMException; | ||
static NotImplementedError: DOMException; | ||
constructor(name: string, message?: string); | ||
} | ||
export declare class DOMStringSizeError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message?: string); | ||
} | ||
export declare class WrongDocumentError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message?: string); | ||
} | ||
export declare class NoDataAllowedError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message?: string); | ||
} | ||
export declare class NoModificationAllowedError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message?: string); | ||
} | ||
export declare class NotSupportedError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message?: string); | ||
} | ||
export declare class InUseAttributeError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message?: string); | ||
} | ||
export declare class InvalidStateError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message?: string); | ||
} | ||
export declare class InvalidModificationError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message?: string); | ||
} | ||
export declare class NamespaceError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message?: string); | ||
} | ||
export declare class InvalidAccessError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message?: string); | ||
} | ||
export declare class ValidationError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message?: string); | ||
} | ||
export declare class TypeMismatchError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message?: string); | ||
} | ||
export declare class SecurityError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message?: string); | ||
} | ||
export declare class NetworkError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message?: string); | ||
} | ||
export declare class AbortError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message?: string); | ||
} | ||
export declare class URLMismatchError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message?: string); | ||
} | ||
export declare class QuotaExceededError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message?: string); | ||
} | ||
export declare class TimeoutError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message?: string); | ||
} | ||
export declare class InvalidNodeTypeError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message?: string); | ||
} | ||
export declare class DataCloneError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message?: string); | ||
} | ||
export declare class NotImplementedError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message?: string); | ||
} | ||
export declare class HierarchyRequestError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message?: string); | ||
} | ||
export declare class NotFoundError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message?: string); | ||
} | ||
export declare class IndexSizeError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message?: string); | ||
} | ||
export declare class SyntaxError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message?: string); | ||
} | ||
export declare class InvalidCharacterError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message?: string); | ||
} |
@@ -19,28 +19,236 @@ "use strict"; | ||
exports.DOMException = DOMException; | ||
DOMException.IndexSizeError = new DOMException("IndexSizeError", "The index is not in the allowed range."); | ||
DOMException.DOMStringSizeError = new DOMException("DOMStringSizeError", ""); | ||
DOMException.HierarchyRequestError = new DOMException("HierarchyRequestError", "The operation would yield an incorrect node tree."); | ||
DOMException.WrongDocumentError = new DOMException("WrongDocumentError", "The object is in the wrong document."); | ||
DOMException.InvalidCharacterError = new DOMException("InvalidCharacterError", "The string contains invalid characters."); | ||
DOMException.NoDataAllowedError = new DOMException("NoDataAllowedError", ""); | ||
DOMException.NoModificationAllowedError = new DOMException("NoModificationAllowedError", "The object can not be modified."); | ||
DOMException.NotFoundError = new DOMException("NotFoundError", "The object can not be found here."); | ||
DOMException.NotSupportedError = new DOMException("NotSupportedError", "The operation is not supported."); | ||
DOMException.InUseAttributeError = new DOMException("InUseAttributeError", ""); | ||
DOMException.InvalidStateError = new DOMException("InvalidStateError", "The object is in an invalid state."); | ||
DOMException.SyntaxError = new DOMException("SyntaxError", "The string did not match the expected pattern."); | ||
DOMException.InvalidModificationError = new DOMException("InvalidModificationError", "The object can not be modified in this way."); | ||
DOMException.NamespaceError = new DOMException("NamespaceError", "The operation is not allowed by Namespaces in XML. [XMLNS]"); | ||
DOMException.InvalidAccessError = new DOMException("InvalidAccessError", "The object does not support the operation or argument."); | ||
DOMException.ValidationError = new DOMException("ValidationError", ""); | ||
DOMException.TypeMismatchError = new DOMException("TypeMismatchError", ""); | ||
DOMException.SecurityError = new DOMException("SecurityError", "The operation is insecure."); | ||
DOMException.NetworkError = new DOMException("NetworkError", "A network error occurred."); | ||
DOMException.AbortError = new DOMException("AbortError", "The operation was aborted."); | ||
DOMException.URLMismatchError = new DOMException("URLMismatchError", "The given URL does not match another URL."); | ||
DOMException.QuotaExceededError = new DOMException("QuotaExceededError", "The quota has been exceeded."); | ||
DOMException.TimeoutError = new DOMException("TimeoutError", "The operation timed out."); | ||
DOMException.InvalidNodeTypeError = new DOMException("InvalidNodeTypeError", "The supplied node is incorrect or has an incorrect ancestor for this operation."); | ||
DOMException.DataCloneError = new DOMException("DataCloneError", "The object can not be cloned."); | ||
DOMException.NotImplementedError = new DOMException("NotImplementedError", "The DOM method is not implemented by this module."); | ||
class DOMStringSizeError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message) { | ||
super("DOMStringSizeError", message || ""); | ||
} | ||
} | ||
exports.DOMStringSizeError = DOMStringSizeError; | ||
class WrongDocumentError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message) { | ||
super("WrongDocumentError", "The object is in the wrong document. " + message || ""); | ||
} | ||
} | ||
exports.WrongDocumentError = WrongDocumentError; | ||
class NoDataAllowedError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message) { | ||
super("NoDataAllowedError", message || ""); | ||
} | ||
} | ||
exports.NoDataAllowedError = NoDataAllowedError; | ||
class NoModificationAllowedError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message) { | ||
super("NoModificationAllowedError", "The object can not be modified. " + message || ""); | ||
} | ||
} | ||
exports.NoModificationAllowedError = NoModificationAllowedError; | ||
class NotSupportedError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message) { | ||
super("NotSupportedError", "The operation is not supported. " + message || ""); | ||
} | ||
} | ||
exports.NotSupportedError = NotSupportedError; | ||
class InUseAttributeError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message) { | ||
super("InUseAttributeError", message || ""); | ||
} | ||
} | ||
exports.InUseAttributeError = InUseAttributeError; | ||
class InvalidStateError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message) { | ||
super("InvalidStateError", "The object is in an invalid state. " + message || ""); | ||
} | ||
} | ||
exports.InvalidStateError = InvalidStateError; | ||
class InvalidModificationError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message) { | ||
super("InvalidModificationError", "The object can not be modified in this way. " + message || ""); | ||
} | ||
} | ||
exports.InvalidModificationError = InvalidModificationError; | ||
class NamespaceError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message) { | ||
super("NamespaceError", "The operation is not allowed by Namespaces in XML. [XMLNS] " + message || ""); | ||
} | ||
} | ||
exports.NamespaceError = NamespaceError; | ||
class InvalidAccessError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message) { | ||
super("InvalidAccessError", "The object does not support the operation or argument. " + message || ""); | ||
} | ||
} | ||
exports.InvalidAccessError = InvalidAccessError; | ||
class ValidationError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message) { | ||
super("ValidationError", message || ""); | ||
} | ||
} | ||
exports.ValidationError = ValidationError; | ||
class TypeMismatchError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message) { | ||
super("TypeMismatchError", message || ""); | ||
} | ||
} | ||
exports.TypeMismatchError = TypeMismatchError; | ||
class SecurityError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message) { | ||
super("SecurityError", "The operation is insecure. " + message || ""); | ||
} | ||
} | ||
exports.SecurityError = SecurityError; | ||
class NetworkError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message) { | ||
super("NetworkError", "A network error occurred. " + message || ""); | ||
} | ||
} | ||
exports.NetworkError = NetworkError; | ||
class AbortError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message) { | ||
super("AbortError", "The operation was aborted. " + message || ""); | ||
} | ||
} | ||
exports.AbortError = AbortError; | ||
class URLMismatchError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message) { | ||
super("URLMismatchError", "The given URL does not match another URL. " + message || ""); | ||
} | ||
} | ||
exports.URLMismatchError = URLMismatchError; | ||
class QuotaExceededError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message) { | ||
super("QuotaExceededError", "The quota has been exceeded. " + message || ""); | ||
} | ||
} | ||
exports.QuotaExceededError = QuotaExceededError; | ||
class TimeoutError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message) { | ||
super("TimeoutError", "The operation timed out. " + message || ""); | ||
} | ||
} | ||
exports.TimeoutError = TimeoutError; | ||
class InvalidNodeTypeError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message) { | ||
super("InvalidNodeTypeError", "The supplied node is incorrect or has an incorrect ancestor for this operation. " + message || ""); | ||
} | ||
} | ||
exports.InvalidNodeTypeError = InvalidNodeTypeError; | ||
class DataCloneError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message) { | ||
super("DataCloneError", "The object can not be cloned. " + message || ""); | ||
} | ||
} | ||
exports.DataCloneError = DataCloneError; | ||
class NotImplementedError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message) { | ||
super("NotImplementedError", "The DOM method is not implemented by this module. " + message || ""); | ||
} | ||
} | ||
exports.NotImplementedError = NotImplementedError; | ||
class HierarchyRequestError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message) { | ||
super("HierarchyRequestError", "The operation would yield an incorrect node tree. " + message || ""); | ||
} | ||
} | ||
exports.HierarchyRequestError = HierarchyRequestError; | ||
class NotFoundError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message) { | ||
super("NotFoundError", "The object can not be found here. " + message || ""); | ||
} | ||
} | ||
exports.NotFoundError = NotFoundError; | ||
class IndexSizeError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message) { | ||
super("NotFoundError", "The index is not in the allowed range. " + message || ""); | ||
} | ||
} | ||
exports.IndexSizeError = IndexSizeError; | ||
class SyntaxError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message) { | ||
super("SyntaxError", "The string did not match the expected pattern. " + message || ""); | ||
} | ||
} | ||
exports.SyntaxError = SyntaxError; | ||
class InvalidCharacterError extends DOMException { | ||
/** | ||
* @param message - error message | ||
*/ | ||
constructor(message) { | ||
super("InvalidCharacterError", "The string contains invalid characters. " + message || ""); | ||
} | ||
} | ||
exports.InvalidCharacterError = InvalidCharacterError; | ||
//# sourceMappingURL=DOMException.js.map |
@@ -15,3 +15,3 @@ "use strict"; | ||
this._associatedDocument = document; | ||
this._algo = util_1.globalStore.algorithm; | ||
this._algo = util_1.globalStore.dom.algorithm; | ||
} | ||
@@ -67,7 +67,7 @@ /** @inheritdoc */ | ||
if (namespace === infra_1.namespace.HTML) | ||
document._contentType = 'application/xhtml+xml'; | ||
document._contentType = "application/xhtml+xml"; | ||
else if (namespace === infra_1.namespace.SVG) | ||
document._contentType = 'image/svg+xml'; | ||
document._contentType = "image/svg+xml"; | ||
else | ||
document._contentType = 'application/xml'; | ||
document._contentType = "application/xml"; | ||
/** | ||
@@ -86,3 +86,3 @@ * 8. Return document. | ||
doc._type = "html"; | ||
doc._contentType = 'text/html'; | ||
doc._contentType = "text/html"; | ||
/** | ||
@@ -92,3 +92,3 @@ * 3. Append a new doctype, with "html" as its name and with its node | ||
*/ | ||
doc.appendChild(this._algo.create.documentType(doc, 'html', '', '')); | ||
doc.appendChild(this._algo.create.documentType(doc, "html", "", "")); | ||
/** | ||
@@ -98,3 +98,3 @@ * 4. Append the result of creating an element given doc, html, and the | ||
*/ | ||
const htmlElement = this._algo.element.createAnElement(doc, 'html', infra_1.namespace.HTML); | ||
const htmlElement = this._algo.element.createAnElement(doc, "html", infra_1.namespace.HTML); | ||
doc.appendChild(htmlElement); | ||
@@ -105,3 +105,3 @@ /** | ||
*/ | ||
const headElement = this._algo.element.createAnElement(doc, 'head', infra_1.namespace.HTML); | ||
const headElement = this._algo.element.createAnElement(doc, "head", infra_1.namespace.HTML); | ||
htmlElement.appendChild(headElement); | ||
@@ -117,3 +117,3 @@ /** | ||
if (title !== undefined) { | ||
const titleElement = this._algo.element.createAnElement(doc, 'title', infra_1.namespace.HTML); | ||
const titleElement = this._algo.element.createAnElement(doc, "title", infra_1.namespace.HTML); | ||
headElement.appendChild(titleElement); | ||
@@ -127,3 +127,3 @@ const textElement = this._algo.create.text(doc, title); | ||
*/ | ||
const bodyElement = this._algo.element.createAnElement(doc, 'body', infra_1.namespace.HTML); | ||
const bodyElement = this._algo.element.createAnElement(doc, "body", infra_1.namespace.HTML); | ||
htmlElement.appendChild(bodyElement); | ||
@@ -130,0 +130,0 @@ /** |
@@ -37,5 +37,7 @@ import { DOMTokenList, Element, Attr } from "./interfaces"; | ||
set value(value: string); | ||
/** @inheritdoc */ | ||
[Symbol.iterator](): IterableIterator<string>; | ||
/** | ||
* Returns an iterator for the token set. | ||
*/ | ||
[Symbol.iterator](): Iterator<string>; | ||
/** | ||
* Creates a new `DOMTokenList`. | ||
@@ -42,0 +44,0 @@ * |
@@ -17,3 +17,3 @@ "use strict"; | ||
constructor(element, attribute) { | ||
this._algo = util_1.globalStore.algorithm; | ||
this._algo = util_1.globalStore.dom.algorithm; | ||
/** | ||
@@ -96,6 +96,6 @@ * 1. Let element be associated element. | ||
if (token === '') { | ||
throw new SyntaxError("Cannot add an empty token."); | ||
throw new DOMException_1.SyntaxError("Cannot add an empty token."); | ||
} | ||
else if (infra_1.codePoint.ASCIIWhiteSpace.test(token)) { | ||
throw DOMException_1.DOMException.InvalidCharacterError; | ||
throw new DOMException_1.InvalidCharacterError("Token cannot contain whitespace."); | ||
} | ||
@@ -121,6 +121,6 @@ else { | ||
if (token === '') { | ||
throw new SyntaxError("Cannot remove an empty token."); | ||
throw new DOMException_1.SyntaxError("Cannot remove an empty token."); | ||
} | ||
else if (infra_1.codePoint.ASCIIWhiteSpace.test(token)) { | ||
throw DOMException_1.DOMException.InvalidCharacterError; | ||
throw new DOMException_1.InvalidCharacterError("Token cannot contain whitespace."); | ||
} | ||
@@ -141,6 +141,6 @@ else { | ||
if (token === '') { | ||
throw new SyntaxError("Cannot toggle an empty token."); | ||
throw new DOMException_1.SyntaxError("Cannot toggle an empty token."); | ||
} | ||
else if (infra_1.codePoint.ASCIIWhiteSpace.test(token)) { | ||
throw DOMException_1.DOMException.InvalidCharacterError; | ||
throw new DOMException_1.InvalidCharacterError("Token cannot contain whitespace."); | ||
} | ||
@@ -186,6 +186,6 @@ /** | ||
if (token === '' || newToken === '') { | ||
throw new SyntaxError("Cannot replace an empty token."); | ||
throw new DOMException_1.SyntaxError("Cannot replace an empty token."); | ||
} | ||
else if (infra_1.codePoint.ASCIIWhiteSpace.test(token) || infra_1.codePoint.ASCIIWhiteSpace.test(newToken)) { | ||
throw DOMException_1.DOMException.InvalidCharacterError; | ||
throw new DOMException_1.InvalidCharacterError("Token cannot contain whitespace."); | ||
} | ||
@@ -231,5 +231,12 @@ /** | ||
} | ||
/** @inheritdoc */ | ||
*[Symbol.iterator]() { | ||
yield* this._tokenSet; | ||
/** | ||
* Returns an iterator for the token set. | ||
*/ | ||
[Symbol.iterator]() { | ||
const it = this._tokenSet[Symbol.iterator](); | ||
return { | ||
next() { | ||
return it.next(); | ||
} | ||
}; | ||
} | ||
@@ -236,0 +243,0 @@ /** |
@@ -29,4 +29,6 @@ "use strict"; | ||
this._attributeList = this._algo.create.namedNodeMap(this); | ||
this._attributeChangeSteps.push(this._updateASlotablesName); | ||
this._attributeChangeSteps.push(this._updateASlotsName); | ||
if (util_1.globalStore.dom.features.slots) { | ||
this._attributeChangeSteps.push(this._updateASlotablesName); | ||
this._attributeChangeSteps.push(this._updateASlotsName); | ||
} | ||
this._attributeChangeSteps.push(this._updateAnElementID); | ||
@@ -86,4 +88,3 @@ } | ||
for (const attr of this._attributeList) { | ||
const attrInt = attr; | ||
names.push(attrInt._qualifiedName); | ||
names.push(attr._qualifiedName); | ||
} | ||
@@ -121,3 +122,3 @@ return names; | ||
if (!this._algo.xml.isName(qualifiedName)) | ||
throw DOMException_1.DOMException.InvalidCharacterError; | ||
throw new DOMException_1.InvalidCharacterError(); | ||
/** | ||
@@ -137,5 +138,4 @@ * 2. If the context object is in the HTML namespace and its node document | ||
for (const attr of this._attributeList) { | ||
const attrInt = attr; | ||
if (attrInt._qualifiedName === qualifiedName) { | ||
attribute = attrInt; | ||
if (attr._qualifiedName === qualifiedName) { | ||
attribute = attr; | ||
break; | ||
@@ -203,4 +203,3 @@ } | ||
for (const attr of this._attributeList) { | ||
const attrInt = attr; | ||
if (attrInt._qualifiedName === qualifiedName) { | ||
if (attr._qualifiedName === qualifiedName) { | ||
return true; | ||
@@ -218,3 +217,3 @@ } | ||
if (!this._algo.xml.isName(qualifiedName)) | ||
throw DOMException_1.DOMException.InvalidCharacterError; | ||
throw new DOMException_1.InvalidCharacterError(); | ||
/** | ||
@@ -234,5 +233,4 @@ * 2. If the context object is in the HTML namespace and its node document | ||
for (const attr of this._attributeList) { | ||
const attrInt = attr; | ||
if (attrInt._qualifiedName === qualifiedName) { | ||
attribute = attrInt; | ||
if (attr._qualifiedName === qualifiedName) { | ||
attribute = attr; | ||
break; | ||
@@ -280,4 +278,3 @@ } | ||
for (const attr of this._attributeList) { | ||
const attrInt = attr; | ||
if (attrInt._namespace === ns && attrInt._localName === localName) { | ||
if (attr._namespace === ns && attr._localName === localName) { | ||
return true; | ||
@@ -334,3 +331,3 @@ } | ||
if (!found) | ||
throw DOMException_1.DOMException.NotFoundError; | ||
throw new DOMException_1.NotFoundError(); | ||
this._algo.element.remove(attr, this); | ||
@@ -346,3 +343,3 @@ return attr; | ||
if (this._namespace !== infra_1.namespace.HTML) | ||
throw DOMException_1.DOMException.NotSupportedError; | ||
throw new DOMException_1.NotSupportedError(); | ||
/** | ||
@@ -356,3 +353,3 @@ * 2. If context object’s local name is not a valid custom element name, | ||
!this._algo.customElement.isValidShadowHostName(this._localName)) | ||
throw DOMException_1.DOMException.NotSupportedError; | ||
throw new DOMException_1.NotSupportedError(); | ||
/** | ||
@@ -370,3 +367,3 @@ * 3. If context object’s local name is a valid custom element name, | ||
if (definition !== null && definition.disableShadow === true) { | ||
throw DOMException_1.DOMException.NotSupportedError; | ||
throw new DOMException_1.NotSupportedError(); | ||
} | ||
@@ -379,3 +376,3 @@ } | ||
if (this._shadowRoot !== null) | ||
throw DOMException_1.DOMException.NotSupportedError; | ||
throw new DOMException_1.NotSupportedError(); | ||
/** | ||
@@ -418,3 +415,3 @@ * 5. Let shadow be a new shadow root whose node document is context | ||
*/ | ||
throw DOMException_1.DOMException.NotImplementedError; | ||
throw new DOMException_1.NotImplementedError(); | ||
} | ||
@@ -431,3 +428,3 @@ /** @inheritdoc */ | ||
*/ | ||
throw DOMException_1.DOMException.NotImplementedError; | ||
throw new DOMException_1.NotImplementedError(); | ||
} | ||
@@ -574,3 +571,3 @@ /** @inheritdoc */ | ||
} | ||
const algo = util_1.globalStore.algorithm; | ||
const algo = util_1.globalStore.dom.algorithm; | ||
algo.shadowTree.assignSlotablesForATree(algo.tree.rootNode(element)); | ||
@@ -608,3 +605,3 @@ } | ||
} | ||
const algo = util_1.globalStore.algorithm; | ||
const algo = util_1.globalStore.dom.algorithm; | ||
if (algo.shadowTree.isAssigned(element)) { | ||
@@ -646,3 +643,2 @@ algo.shadowTree.assignSlotables(element._assignedSlot); | ||
node._namespacePrefix = namespacePrefix; | ||
node._attributeList = node._algo.create.namedNodeMap(node); | ||
node._nodeDocument = document; | ||
@@ -649,0 +645,0 @@ return node; |
@@ -33,3 +33,3 @@ "use strict"; | ||
this._cancelable = false; | ||
this._algo = util_1.globalStore.algorithm; | ||
this._algo = util_1.globalStore.dom.algorithm; | ||
/** | ||
@@ -36,0 +36,0 @@ * When a constructor of the Event interface, or of an interface that |
@@ -15,3 +15,3 @@ "use strict"; | ||
this._eventHandlerMap = new Map(); | ||
this._algo = util_1.globalStore.algorithm; | ||
this._algo = util_1.globalStore.dom.algorithm; | ||
} | ||
@@ -93,3 +93,3 @@ /** @inheritdoc */ | ||
if (event._dispatchFlag || !event._initializedFlag) { | ||
throw DOMException_1.DOMException.InvalidStateError; | ||
throw new DOMException_1.InvalidStateError(); | ||
} | ||
@@ -96,0 +96,0 @@ event._isTrusted = false; |
@@ -8,3 +8,3 @@ import { Node, Element, HTMLCollection } from "./interfaces"; | ||
_root: Node; | ||
_filter: ((element: Element) => any); | ||
_filter: ((element: Element) => boolean); | ||
protected static reservedNames: string[]; | ||
@@ -25,3 +25,3 @@ /** | ||
/** @inheritdoc */ | ||
[Symbol.iterator](): IterableIterator<Element>; | ||
[Symbol.iterator](): Iterator<Element>; | ||
/** @inheritdoc */ | ||
@@ -41,3 +41,3 @@ [index: number]: any; | ||
*/ | ||
static _create(root: Node, filter?: ((element: Element) => any)): HTMLCollectionImpl; | ||
static _create(root: Node, filter?: ((element: Element) => boolean)): HTMLCollectionImpl; | ||
} |
@@ -62,12 +62,10 @@ "use strict"; | ||
for (const ele of this) { | ||
const eleInt = ele; | ||
if (eleInt._uniqueIdentifier === key) { | ||
return eleInt; | ||
if (ele._uniqueIdentifier === key) { | ||
return ele; | ||
} | ||
else if (eleInt._namespace === infra_1.namespace.HTML) { | ||
for (const attr of eleInt._attributeList) { | ||
const attrInt = attr; | ||
if (attrInt._localName === "name" && attrInt._namespace === null && | ||
attrInt._namespacePrefix === null && attrInt._value === key) | ||
return eleInt; | ||
else if (ele._namespace === infra_1.namespace.HTML) { | ||
for (const attr of ele._attributeList) { | ||
if (attr._localName === "name" && attr._namespace === null && | ||
attr._namespacePrefix === null && attr._value === key) | ||
return ele; | ||
} | ||
@@ -79,5 +77,18 @@ } | ||
/** @inheritdoc */ | ||
*[Symbol.iterator]() { | ||
const algo = util_1.globalStore.algorithm; | ||
yield* algo.tree.getDescendantElements(this._root, false, false, (ele) => { return !!this._filter(ele); }); | ||
[Symbol.iterator]() { | ||
const algo = util_1.globalStore.dom.algorithm; | ||
const it = algo.tree.getDescendantElements(this._root, false, false, (ele) => { return !!this._filter(ele); })[Symbol.iterator](); | ||
let currentNode = it.next().value; | ||
return { | ||
next() { | ||
if (currentNode === null) { | ||
return { done: true, value: null }; | ||
} | ||
else { | ||
const result = { done: false, value: currentNode }; | ||
currentNode = it.next().value; | ||
return result; | ||
} | ||
} | ||
}; | ||
} | ||
@@ -84,0 +95,0 @@ /** |
@@ -24,3 +24,3 @@ "use strict"; | ||
this._callback = callback; | ||
const window = util_1.globalStore.window; | ||
const window = util_1.globalStore.dom.window; | ||
infra_1.set.append(window._mutationObservers, this); | ||
@@ -82,3 +82,3 @@ } | ||
for (const node of this._nodeList) { | ||
infra_1.list.remove(node._registeredObserverList, (ob) => util_1.Guard.isTransientRegisteredObserver(ob) && ob.source === registered); | ||
infra_1.list.remove((node)._registeredObserverList, (ob) => util_1.Guard.isTransientRegisteredObserver(ob) && ob.source === registered); | ||
} | ||
@@ -110,3 +110,3 @@ /** | ||
for (const node of this._nodeList) { | ||
infra_1.list.remove(node._registeredObserverList, (ob) => ob.observer === this); | ||
infra_1.list.remove((node)._registeredObserverList, (ob) => ob.observer === this); | ||
} | ||
@@ -113,0 +113,0 @@ /** |
@@ -32,5 +32,5 @@ import { Element, Attr, NamedNodeMap } from "./interfaces"; | ||
/** | ||
* Returns an iterator for nodes. | ||
* Returns an iterator for attributes. | ||
*/ | ||
[Symbol.iterator](): IterableIterator<Attr>; | ||
[Symbol.iterator](): Iterator<Attr>; | ||
/** | ||
@@ -37,0 +37,0 @@ * Creates a new `NamedNodeMap`. |
@@ -16,3 +16,3 @@ "use strict"; | ||
this._attributeList = []; | ||
this._algo = util_1.globalStore.algorithm; | ||
this._algo = util_1.globalStore.dom.algorithm; | ||
this._element = element; | ||
@@ -76,3 +76,3 @@ } | ||
if (attr === null) | ||
throw DOMException_1.DOMException.NotFoundError; | ||
throw new DOMException_1.NotFoundError(); | ||
return attr; | ||
@@ -90,10 +90,15 @@ } | ||
if (attr === null) | ||
throw DOMException_1.DOMException.NotFoundError; | ||
throw new DOMException_1.NotFoundError(); | ||
return attr; | ||
} | ||
/** | ||
* Returns an iterator for nodes. | ||
* Returns an iterator for attributes. | ||
*/ | ||
*[Symbol.iterator]() { | ||
yield* this._attributeList; | ||
[Symbol.iterator]() { | ||
const it = this._attributeList[Symbol.iterator](); | ||
return { | ||
next() { | ||
return it.next(); | ||
} | ||
}; | ||
} | ||
@@ -100,0 +105,0 @@ /** |
@@ -45,3 +45,3 @@ "use strict"; | ||
} | ||
get _nodeDocument() { return this._nodeDocumentOverride || util_1.globalStore.window._associatedDocument; } | ||
get _nodeDocument() { return this._nodeDocumentOverride || util_1.globalStore.dom.window._associatedDocument; } | ||
set _nodeDocument(val) { this._nodeDocumentOverride = val; } | ||
@@ -175,3 +175,3 @@ /** @inheritdoc */ | ||
*/ | ||
return (this.firstChild !== null); | ||
return (this._firstChild !== null); | ||
} | ||
@@ -341,41 +341,43 @@ /** | ||
*/ | ||
let currentNode = node.nextSibling; | ||
while (currentNode !== null && util_1.Guard.isExclusiveTextNode(currentNode)) { | ||
/** | ||
* 6.1. For each live range whose start node is currentNode, add length | ||
* to its start offset and set its start node to node. | ||
* 6.2. For each live range whose end node is currentNode, add length to | ||
* its end offset and set its end node to node. | ||
* 6.3. For each live range whose start node is currentNode’s parent and | ||
* start offset is currentNode’s index, set its start node to node and | ||
* its start offset to length. | ||
* 6.4. For each live range whose end node is currentNode’s parent and | ||
* end offset is currentNode’s index, set its end node to node and its | ||
* end offset to length. | ||
*/ | ||
const index = algo.tree.index(currentNode); | ||
for (const range of algo.range.rangeList) { | ||
if (range._start[0] === currentNode) { | ||
range._start[0] = node; | ||
range._start[1] += length; | ||
if (this._algo.range.rangeList.length !== 0) { | ||
let currentNode = node._nextSibling; | ||
while (currentNode !== null && util_1.Guard.isExclusiveTextNode(currentNode)) { | ||
/** | ||
* 6.1. For each live range whose start node is currentNode, add length | ||
* to its start offset and set its start node to node. | ||
* 6.2. For each live range whose end node is currentNode, add length to | ||
* its end offset and set its end node to node. | ||
* 6.3. For each live range whose start node is currentNode’s parent and | ||
* start offset is currentNode’s index, set its start node to node and | ||
* its start offset to length. | ||
* 6.4. For each live range whose end node is currentNode’s parent and | ||
* end offset is currentNode’s index, set its end node to node and its | ||
* end offset to length. | ||
*/ | ||
const index = algo.tree.index(currentNode); | ||
for (const range of algo.range.rangeList) { | ||
if (range._start[0] === currentNode) { | ||
range._start[0] = node; | ||
range._start[1] += length; | ||
} | ||
if (range._end[0] === currentNode) { | ||
range._end[0] = node; | ||
range._end[1] += length; | ||
} | ||
if (range._start[0] === currentNode._parent && range._start[1] === index) { | ||
range._start[0] = node; | ||
range._start[1] = length; | ||
} | ||
if (range._end[0] === currentNode._parent && range._end[1] === index) { | ||
range._end[0] = node; | ||
range._end[1] = length; | ||
} | ||
} | ||
if (range._end[0] === currentNode) { | ||
range._end[0] = node; | ||
range._end[1] += length; | ||
} | ||
if (range._start[0] === currentNode._parent && range._start[1] === index) { | ||
range._start[0] = node; | ||
range._start[1] = length; | ||
} | ||
if (range._end[0] === currentNode._parent && range._end[1] === index) { | ||
range._end[0] = node; | ||
range._end[1] = length; | ||
} | ||
/** | ||
* 6.5. Add currentNode’s length to length. | ||
* 6.6. Set currentNode to its next sibling. | ||
*/ | ||
length += algo.tree.nodeLength(currentNode); | ||
currentNode = currentNode._nextSibling; | ||
} | ||
/** | ||
* 6.5. Add currentNode’s length to length. | ||
* 6.6. Set currentNode to its next sibling. | ||
*/ | ||
length += algo.tree.nodeLength(currentNode); | ||
currentNode = currentNode.nextSibling; | ||
} | ||
@@ -410,3 +412,3 @@ /** | ||
if (util_1.Guard.isShadowRoot(this)) | ||
throw DOMException_1.DOMException.NotSupportedError; | ||
throw new DOMException_1.NotSupportedError(); | ||
return this._algo.node.clone(this, null, deep); | ||
@@ -511,3 +513,3 @@ } | ||
return interfaces_1.Position.Disconnected | interfaces_1.Position.ImplementationSpecific | | ||
(util_1.globalStore.compareCache.check(this, other) ? interfaces_1.Position.Preceding : interfaces_1.Position.Following); | ||
(util_1.globalStore.dom.compareCache.check(this, other) ? interfaces_1.Position.Preceding : interfaces_1.Position.Following); | ||
} | ||
@@ -514,0 +516,0 @@ /** |
@@ -8,3 +8,3 @@ import { Node, NodeList } from "./interfaces"; | ||
_root: Node; | ||
_filter: ((node: Node) => any); | ||
_filter: ((node: Node) => any) | null; | ||
_length: number; | ||
@@ -22,9 +22,9 @@ /** | ||
/** @inheritdoc */ | ||
keys(): IterableIterator<number>; | ||
keys(): Iterable<number>; | ||
/** @inheritdoc */ | ||
values(): IterableIterator<Node>; | ||
values(): Iterable<Node>; | ||
/** @inheritdoc */ | ||
entries(): IterableIterator<[number, Node]>; | ||
entries(): Iterable<[number, Node]>; | ||
/** @inheritdoc */ | ||
[Symbol.iterator](): IterableIterator<Node>; | ||
[Symbol.iterator](): Iterator<Node>; | ||
/** @inheritdoc */ | ||
@@ -31,0 +31,0 @@ forEach(callback: (node: Node, index: number, list: NodeList) => any, thisArg?: any): void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const infra_1 = require("@oozcitak/infra"); | ||
const util_1 = require("../util"); | ||
@@ -16,3 +15,3 @@ /** | ||
this._live = true; | ||
this._filter = (() => true); | ||
this._filter = null; | ||
this._length = 0; | ||
@@ -27,3 +26,3 @@ this._root = root; | ||
*/ | ||
return infra_1.set.size(this._root._children); | ||
return this._root._children.size; | ||
} | ||
@@ -41,5 +40,5 @@ /** @inheritdoc */ | ||
let i = 0; | ||
let node = this._root.firstChild; | ||
let node = this._root._firstChild; | ||
while (node !== null && i !== index) { | ||
node = node.nextSibling; | ||
node = node._nextSibling; | ||
i++; | ||
@@ -51,5 +50,5 @@ } | ||
let i = this.length - 1; | ||
let node = this._root.lastChild; | ||
let node = this._root._lastChild; | ||
while (node !== null && i !== index) { | ||
node = node.previousSibling; | ||
node = node._previousSibling; | ||
i--; | ||
@@ -61,21 +60,60 @@ } | ||
/** @inheritdoc */ | ||
*keys() { | ||
for (let i = 0; i < this.length; i++) { | ||
yield i; | ||
} | ||
keys() { | ||
return { | ||
[Symbol.iterator]: function () { | ||
let index = 0; | ||
return { | ||
next: function () { | ||
if (index === this.length) { | ||
return { done: true, value: null }; | ||
} | ||
else { | ||
return { done: false, value: index++ }; | ||
} | ||
}.bind(this) | ||
}; | ||
}.bind(this) | ||
}; | ||
} | ||
/** @inheritdoc */ | ||
*values() { | ||
yield* this; | ||
values() { | ||
return { | ||
[Symbol.iterator]: function () { | ||
const it = this[Symbol.iterator](); | ||
return { | ||
next() { | ||
return it.next(); | ||
} | ||
}; | ||
}.bind(this) | ||
}; | ||
} | ||
/** @inheritdoc */ | ||
*entries() { | ||
let index = 0; | ||
for (const child of this) { | ||
yield [index++, child]; | ||
} | ||
entries() { | ||
return { | ||
[Symbol.iterator]: function () { | ||
const it = this[Symbol.iterator](); | ||
let index = 0; | ||
return { | ||
next() { | ||
const itResult = it.next(); | ||
if (itResult.done) { | ||
return { done: true, value: null }; | ||
} | ||
else { | ||
return { done: false, value: [index++, itResult.value] }; | ||
} | ||
} | ||
}; | ||
}.bind(this) | ||
}; | ||
} | ||
/** @inheritdoc */ | ||
*[Symbol.iterator]() { | ||
yield* this._root._children; | ||
[Symbol.iterator]() { | ||
const it = this._root._children[Symbol.iterator](); | ||
return { | ||
next() { | ||
return it.next(); | ||
} | ||
}; | ||
} | ||
@@ -85,3 +123,3 @@ /** @inheritdoc */ | ||
if (thisArg === undefined) { | ||
thisArg = util_1.globalStore.window; | ||
thisArg = util_1.globalStore.dom.window; | ||
} | ||
@@ -88,0 +126,0 @@ for (const [index, node] of this.entries()) { |
@@ -23,9 +23,9 @@ import { Node, NodeList } from "./interfaces"; | ||
/** @inheritdoc */ | ||
keys(): IterableIterator<number>; | ||
keys(): Iterable<number>; | ||
/** @inheritdoc */ | ||
values(): IterableIterator<Node>; | ||
values(): Iterable<Node>; | ||
/** @inheritdoc */ | ||
entries(): IterableIterator<[number, Node]>; | ||
entries(): Iterable<[number, Node]>; | ||
/** @inheritdoc */ | ||
[Symbol.iterator](): IterableIterator<Node>; | ||
[Symbol.iterator](): Iterator<Node>; | ||
/** @inheritdoc */ | ||
@@ -32,0 +32,0 @@ forEach(callback: (node: Node, index: number, list: NodeList) => any, thisArg?: any): void; |
@@ -42,23 +42,60 @@ "use strict"; | ||
/** @inheritdoc */ | ||
*keys() { | ||
for (let index = 0; index < this._items.length; index++) { | ||
yield index; | ||
} | ||
keys() { | ||
return { | ||
[Symbol.iterator]: function () { | ||
let index = 0; | ||
return { | ||
next: function () { | ||
if (index === this.length) { | ||
return { done: true, value: null }; | ||
} | ||
else { | ||
return { done: false, value: index++ }; | ||
} | ||
}.bind(this) | ||
}; | ||
}.bind(this) | ||
}; | ||
} | ||
/** @inheritdoc */ | ||
*values() { | ||
yield* this; | ||
values() { | ||
return { | ||
[Symbol.iterator]: function () { | ||
const it = this[Symbol.iterator](); | ||
return { | ||
next() { | ||
return it.next(); | ||
} | ||
}; | ||
}.bind(this) | ||
}; | ||
} | ||
/** @inheritdoc */ | ||
*entries() { | ||
let index = 0; | ||
for (const child of this._items) { | ||
yield [index++, child]; | ||
} | ||
entries() { | ||
return { | ||
[Symbol.iterator]: function () { | ||
const it = this[Symbol.iterator](); | ||
let index = 0; | ||
return { | ||
next() { | ||
const itResult = it.next(); | ||
if (itResult.done) { | ||
return { done: true, value: null }; | ||
} | ||
else { | ||
return { done: false, value: [index++, itResult.value] }; | ||
} | ||
} | ||
}; | ||
}.bind(this) | ||
}; | ||
} | ||
/** @inheritdoc */ | ||
*[Symbol.iterator]() { | ||
for (const node of this._items) { | ||
yield node; | ||
} | ||
[Symbol.iterator]() { | ||
const it = this._items[Symbol.iterator](); | ||
return { | ||
next() { | ||
return it.next(); | ||
} | ||
}; | ||
} | ||
@@ -68,3 +105,3 @@ /** @inheritdoc */ | ||
if (thisArg === undefined) { | ||
thisArg = util_1.globalStore.window; | ||
thisArg = util_1.globalStore.dom.window; | ||
} | ||
@@ -71,0 +108,0 @@ for (const [index, node] of this.entries()) { |
@@ -16,3 +16,3 @@ "use strict"; | ||
*/ | ||
let node = util_1.Cast.asNode(this).previousSibling; | ||
let node = util_1.Cast.asNode(this)._previousSibling; | ||
while (node) { | ||
@@ -22,3 +22,3 @@ if (util_1.Guard.isElementNode(node)) | ||
else | ||
node = node.previousSibling; | ||
node = node._previousSibling; | ||
} | ||
@@ -33,3 +33,3 @@ return null; | ||
*/ | ||
let node = util_1.Cast.asNode(this).nextSibling; | ||
let node = util_1.Cast.asNode(this)._nextSibling; | ||
while (node) { | ||
@@ -39,3 +39,3 @@ if (util_1.Guard.isElementNode(node)) | ||
else | ||
node = node.nextSibling; | ||
node = node._nextSibling; | ||
} | ||
@@ -42,0 +42,0 @@ return null; |
@@ -16,3 +16,3 @@ "use strict"; | ||
*/ | ||
const algo = util_1.globalStore.algorithm; | ||
const algo = util_1.globalStore.dom.algorithm; | ||
for (const ele of algo.tree.getDescendantElements(util_1.Cast.asNode(this))) { | ||
@@ -19,0 +19,0 @@ if (ele._uniqueIdentifier === id) { |
@@ -16,3 +16,3 @@ "use strict"; | ||
*/ | ||
const algo = util_1.globalStore.algorithm; | ||
const algo = util_1.globalStore.dom.algorithm; | ||
return algo.create.htmlCollection(util_1.Cast.asNode(this)); | ||
@@ -26,3 +26,3 @@ } | ||
*/ | ||
let node = util_1.Cast.asNode(this).firstChild; | ||
let node = util_1.Cast.asNode(this)._firstChild; | ||
while (node) { | ||
@@ -32,3 +32,3 @@ if (util_1.Guard.isElementNode(node)) | ||
else | ||
node = node.nextSibling; | ||
node = node._nextSibling; | ||
} | ||
@@ -43,3 +43,3 @@ return null; | ||
*/ | ||
let node = util_1.Cast.asNode(this).lastChild; | ||
let node = util_1.Cast.asNode(this)._lastChild; | ||
while (node) { | ||
@@ -49,3 +49,3 @@ if (util_1.Guard.isElementNode(node)) | ||
else | ||
node = node.previousSibling; | ||
node = node._previousSibling; | ||
} | ||
@@ -60,8 +60,7 @@ return null; | ||
*/ | ||
let node = util_1.Cast.asNode(this).firstChild; | ||
const node = util_1.Cast.asNode(this); | ||
let count = 0; | ||
while (node) { | ||
if (util_1.Guard.isElementNode(node)) | ||
for (const childNode of node._children) { | ||
if (util_1.Guard.isElementNode(childNode)) | ||
count++; | ||
node = node.nextSibling; | ||
} | ||
@@ -78,6 +77,6 @@ return count; | ||
*/ | ||
const algo = util_1.globalStore.algorithm; | ||
const algo = util_1.globalStore.dom.algorithm; | ||
const node = util_1.Cast.asNode(this); | ||
const childNode = algo.parentNode.convertNodesIntoANode(nodes, node._nodeDocument); | ||
algo.mutation.preInsert(childNode, node, node.firstChild); | ||
algo.mutation.preInsert(childNode, node, node._firstChild); | ||
} | ||
@@ -91,3 +90,3 @@ /** @inheritdoc */ | ||
*/ | ||
const algo = util_1.globalStore.algorithm; | ||
const algo = util_1.globalStore.dom.algorithm; | ||
const node = util_1.Cast.asNode(this); | ||
@@ -104,3 +103,3 @@ const childNode = algo.parentNode.convertNodesIntoANode(nodes, node._nodeDocument); | ||
*/ | ||
const algo = util_1.globalStore.algorithm; | ||
const algo = util_1.globalStore.dom.algorithm; | ||
const node = util_1.Cast.asNode(this); | ||
@@ -117,3 +116,3 @@ const result = algo.selectors.scopeMatchASelectorsString(selectors, node); | ||
*/ | ||
const algo = util_1.globalStore.algorithm; | ||
const algo = util_1.globalStore.dom.algorithm; | ||
const node = util_1.Cast.asNode(this); | ||
@@ -120,0 +119,0 @@ const result = algo.selectors.scopeMatchASelectorsString(selectors, node); |
@@ -24,4 +24,4 @@ "use strict"; | ||
*/ | ||
this._algo = util_1.globalStore.algorithm; | ||
const doc = util_1.globalStore.window._associatedDocument; | ||
this._algo = util_1.globalStore.dom.algorithm; | ||
const doc = util_1.globalStore.dom.window._associatedDocument; | ||
this._start = [doc, 0]; | ||
@@ -72,5 +72,5 @@ this._end = [doc, 0]; | ||
*/ | ||
let parent = node.parentNode; | ||
let parent = node._parent; | ||
if (parent === null) | ||
throw DOMException_1.DOMException.InvalidNodeTypeError; | ||
throw new DOMException_1.InvalidNodeTypeError(); | ||
this._algo.range.setTheStart(this, parent, this._algo.tree.index(node)); | ||
@@ -86,5 +86,5 @@ } | ||
*/ | ||
let parent = node.parentNode; | ||
let parent = node._parent; | ||
if (parent === null) | ||
throw DOMException_1.DOMException.InvalidNodeTypeError; | ||
throw new DOMException_1.InvalidNodeTypeError(); | ||
this._algo.range.setTheStart(this, parent, this._algo.tree.index(node) + 1); | ||
@@ -100,5 +100,5 @@ } | ||
*/ | ||
let parent = node.parentNode; | ||
let parent = node._parent; | ||
if (parent === null) | ||
throw DOMException_1.DOMException.InvalidNodeTypeError; | ||
throw new DOMException_1.InvalidNodeTypeError(); | ||
this._algo.range.setTheEnd(this, parent, this._algo.tree.index(node)); | ||
@@ -114,5 +114,5 @@ } | ||
*/ | ||
let parent = node.parentNode; | ||
let parent = node._parent; | ||
if (parent === null) | ||
throw DOMException_1.DOMException.InvalidNodeTypeError; | ||
throw new DOMException_1.InvalidNodeTypeError(); | ||
this._algo.range.setTheEnd(this, parent, this._algo.tree.index(node) + 1); | ||
@@ -150,3 +150,3 @@ } | ||
if (util_1.Guard.isDocumentTypeNode(node)) | ||
throw DOMException_1.DOMException.InvalidNodeTypeError; | ||
throw new DOMException_1.InvalidNodeTypeError(); | ||
const length = this._algo.tree.nodeLength(node); | ||
@@ -168,3 +168,3 @@ this._start = [node, 0]; | ||
how !== interfaces_1.HowToCompare.EndToEnd && how !== interfaces_1.HowToCompare.EndToStart) | ||
throw DOMException_1.DOMException.NotSupportedError; | ||
throw new DOMException_1.NotSupportedError(); | ||
/** | ||
@@ -175,3 +175,3 @@ * 2. If context object’s root is not the same as sourceRange’s root, | ||
if (this._algo.range.root(this) !== this._algo.range.root(sourceRange)) | ||
throw DOMException_1.DOMException.WrongDocumentError; | ||
throw new DOMException_1.WrongDocumentError(); | ||
/** | ||
@@ -213,3 +213,3 @@ * 3. If how is: | ||
default: | ||
throw DOMException_1.DOMException.NotSupportedError; | ||
throw new DOMException_1.NotSupportedError(); | ||
} | ||
@@ -269,3 +269,3 @@ /** | ||
for (const node of this._algo.range.getContainedNodes(this)) { | ||
const parent = node.parentNode; | ||
const parent = node._parent; | ||
if (parent !== null && this._algo.range.isContained(parent, this)) { | ||
@@ -372,4 +372,4 @@ continue; | ||
for (const node of this._algo.range.getPartiallyContainedNodes(this)) { | ||
if (node.nodeType !== interfaces_1.NodeType.Text) { | ||
throw DOMException_1.DOMException.InvalidStateError; | ||
if (!util_1.Guard.isTextNode(node)) { | ||
throw new DOMException_1.InvalidStateError(); | ||
} | ||
@@ -384,3 +384,3 @@ } | ||
util_1.Guard.isDocumentFragmentNode(newParent)) { | ||
throw DOMException_1.DOMException.InvalidNodeTypeError; | ||
throw new DOMException_1.InvalidNodeTypeError(); | ||
} | ||
@@ -394,3 +394,3 @@ /** | ||
*/ | ||
if (newParent._children.size !== 0) { | ||
if ((newParent)._children.size !== 0) { | ||
this._algo.mutation.replaceAll(null, newParent); | ||
@@ -440,5 +440,5 @@ } | ||
if (util_1.Guard.isDocumentTypeNode(node)) | ||
throw DOMException_1.DOMException.InvalidNodeTypeError; | ||
throw new DOMException_1.InvalidNodeTypeError(); | ||
if (offset > this._algo.tree.nodeLength(node)) | ||
throw DOMException_1.DOMException.IndexSizeError; | ||
throw new DOMException_1.IndexSizeError(); | ||
/** | ||
@@ -467,7 +467,7 @@ * 4. If (node, offset) is before start or after end, return false. | ||
if (this._algo.tree.rootNode(node) !== this._algo.range.root(this)) | ||
throw DOMException_1.DOMException.WrongDocumentError; | ||
throw new DOMException_1.WrongDocumentError(); | ||
if (util_1.Guard.isDocumentTypeNode(node)) | ||
throw DOMException_1.DOMException.InvalidNodeTypeError; | ||
throw new DOMException_1.InvalidNodeTypeError(); | ||
if (offset > this._algo.tree.nodeLength(node)) | ||
throw DOMException_1.DOMException.IndexSizeError; | ||
throw new DOMException_1.IndexSizeError(); | ||
/** | ||
@@ -474,0 +474,0 @@ * 4. If (node, offset) is before start, return −1. |
@@ -36,5 +36,4 @@ "use strict"; | ||
*/ | ||
const eventInt = event; | ||
if (!eventInt._composedFlag && !util_1.isEmpty(eventInt._path) && | ||
this._algo.tree.rootNode(eventInt._path[0].invocationTarget) === this) { | ||
if (!event._composedFlag && !util_1.isEmpty(event._path) && | ||
this._algo.tree.rootNode(event._path[0].invocationTarget) === this) { | ||
return null; | ||
@@ -41,0 +40,0 @@ } |
@@ -16,3 +16,3 @@ "use strict"; | ||
get assignedSlot() { | ||
const algo = util_1.globalStore.algorithm; | ||
const algo = util_1.globalStore.dom.algorithm; | ||
return algo.shadowTree.findASlot(this, true); | ||
@@ -19,0 +19,0 @@ } |
@@ -25,3 +25,3 @@ "use strict"; | ||
util_1.Guard.isDocumentTypeNode(init.endContainer) || util_1.Guard.isAttrNode(init.endContainer)) { | ||
throw DOMException_1.DOMException.InvalidNodeTypeError; | ||
throw new DOMException_1.InvalidNodeTypeError(); | ||
} | ||
@@ -28,0 +28,0 @@ this._start = [init.startContainer, init.startOffset]; |
@@ -16,3 +16,3 @@ "use strict"; | ||
constructor(root) { | ||
this._algo = util_1.globalStore.algorithm; | ||
this._algo = util_1.globalStore.dom.algorithm; | ||
this._activeFlag = false; | ||
@@ -19,0 +19,0 @@ this._root = root; |
@@ -33,3 +33,3 @@ "use strict"; | ||
*/ | ||
node = node.parentNode; | ||
node = node._parent; | ||
if (node !== null && | ||
@@ -82,3 +82,3 @@ this._algo.traversal.filter(this, node) === interfaces_1.FilterResult.Accept) { | ||
*/ | ||
let sibling = node.previousSibling; | ||
let sibling = node._previousSibling; | ||
while (sibling) { | ||
@@ -95,3 +95,3 @@ /** | ||
*/ | ||
while (result !== interfaces_1.FilterResult.Reject && node.lastChild) { | ||
while (result !== interfaces_1.FilterResult.Reject && node._lastChild) { | ||
/** | ||
@@ -102,3 +102,3 @@ * 2.2.3.1. Set node to node’s last child. | ||
*/ | ||
node = node.lastChild; | ||
node = node._lastChild; | ||
result = this._algo.traversal.filter(this, node); | ||
@@ -117,3 +117,3 @@ } | ||
*/ | ||
sibling = node.previousSibling; | ||
sibling = node._previousSibling; | ||
} | ||
@@ -124,3 +124,3 @@ /** | ||
*/ | ||
if (node === this.root || !node.parentNode) { | ||
if (node === this.root || node._parent === null) { | ||
return null; | ||
@@ -131,3 +131,3 @@ } | ||
*/ | ||
node = node.parentNode; | ||
node = node._parent; | ||
/** | ||
@@ -169,3 +169,3 @@ * 2.5. If the return value of filtering node within the context object is | ||
*/ | ||
while (result !== interfaces_1.FilterResult.Reject && node.firstChild) { | ||
while (result !== interfaces_1.FilterResult.Reject && node._firstChild) { | ||
/** | ||
@@ -178,3 +178,3 @@ * 3.1.1. Set node to its first child. | ||
*/ | ||
node = node.firstChild; | ||
node = node._firstChild; | ||
result = this._algo.traversal.filter(this, node); | ||
@@ -204,3 +204,3 @@ if (result === interfaces_1.FilterResult.Accept) { | ||
*/ | ||
sibling = temporary.nextSibling; | ||
sibling = temporary._nextSibling; | ||
if (sibling !== null) { | ||
@@ -213,3 +213,3 @@ node = sibling; | ||
*/ | ||
temporary = temporary.parentNode; | ||
temporary = temporary._parent; | ||
} | ||
@@ -216,0 +216,0 @@ /** |
@@ -1,8 +0,32 @@ | ||
import * as algorithm from "./algorithm"; | ||
import * as dom from "./dom"; | ||
import * as parser from "./parser"; | ||
import * as serializer from "./serializer"; | ||
import * as util from "./util"; | ||
export { algorithm, dom, parser, serializer, util }; | ||
export declare const window: dom.Interfaces.Window; | ||
export declare const implementation: dom.Interfaces.DOMImplementation; | ||
import { CompareCache } from "@oozcitak/util"; | ||
import { Node, DOM, Window, DOMImplementation, DOMFeatures } from "./dom/interfaces"; | ||
import { DOMAlgorithm } from "./algorithm/interfaces"; | ||
/** | ||
* Represents an object implementing DOM algorithms. | ||
*/ | ||
declare class DOMImpl implements DOM { | ||
private _features; | ||
private _algorithm; | ||
private _window; | ||
private _compareCache; | ||
/** | ||
* Initializes a new instance of `DOM`. | ||
* | ||
* @param features - DOM features supported by algorithms. All features are | ||
* enabled by default unless explicity disabled. | ||
*/ | ||
constructor(features?: Partial<DOMFeatures> | boolean); | ||
/** @inheritdoc */ | ||
get features(): DOMFeatures; | ||
/** @inheritdoc */ | ||
get algorithm(): DOMAlgorithm; | ||
/** @inheritdoc */ | ||
get window(): Window; | ||
/** @inheritdoc */ | ||
get implementation(): DOMImplementation; | ||
/** @inheritdoc */ | ||
get compareCache(): CompareCache<Node>; | ||
} | ||
export { DOMImpl as DOM }; | ||
export { DOMParser } from "./parser"; | ||
export { XMLSerializer } from "./serializer"; |
"use strict"; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const algorithm = __importStar(require("./algorithm")); | ||
exports.algorithm = algorithm; | ||
const dom = __importStar(require("./dom")); | ||
exports.dom = dom; | ||
const parser = __importStar(require("./parser")); | ||
exports.parser = parser; | ||
const serializer = __importStar(require("./serializer")); | ||
exports.serializer = serializer; | ||
const util = __importStar(require("./util")); | ||
exports.util = util; | ||
const util_1 = require("@oozcitak/util"); | ||
const algo = new algorithm.DOMAlgorithm(); | ||
util.globalStore.algorithm = algo; | ||
util.globalStore.window = algo.create.window(); | ||
util.globalStore.compareCache = new util_1.CompareCache(); | ||
exports.window = util.globalStore.window; | ||
exports.implementation = exports.window.document.implementation; | ||
const DOMAlgorithmImpl_1 = require("./algorithm/DOMAlgorithmImpl"); | ||
const util_2 = require("./util"); | ||
/** | ||
* Represents an object implementing DOM algorithms. | ||
*/ | ||
class DOMImpl { | ||
/** | ||
* Initializes a new instance of `DOM`. | ||
* | ||
* @param features - DOM features supported by algorithms. All features are | ||
* enabled by default unless explicity disabled. | ||
*/ | ||
constructor(features) { | ||
this._features = { | ||
mutationObservers: true, | ||
customElements: true, | ||
slots: true | ||
}; | ||
this._window = null; | ||
if (features === undefined) | ||
features = true; | ||
if (util_1.isObject(features)) { | ||
for (const key in features) { | ||
this._features[key] = features[key]; | ||
} | ||
} | ||
else { | ||
// enable/disable all features | ||
for (const key in this._features) { | ||
this._features[key] = features; | ||
} | ||
} | ||
this._algorithm = new DOMAlgorithmImpl_1.DOMAlgorithmImpl(); | ||
this._compareCache = new util_1.CompareCache(); | ||
util_2.globalStore.dom = this; | ||
} | ||
/** @inheritdoc */ | ||
get features() { return this._features; } | ||
/** @inheritdoc */ | ||
get algorithm() { return this._algorithm; } | ||
/** @inheritdoc */ | ||
get window() { | ||
if (this._window === null) { | ||
this._window = this._algorithm.create.window(); | ||
} | ||
return this._window; | ||
} | ||
/** @inheritdoc */ | ||
get implementation() { return this.window.document.implementation; } | ||
/** @inheritdoc */ | ||
get compareCache() { return this._compareCache; } | ||
} | ||
exports.DOM = DOMImpl; | ||
var parser_1 = require("./parser"); | ||
exports.DOMParser = parser_1.DOMParser; | ||
var serializer_1 = require("./serializer"); | ||
exports.XMLSerializer = serializer_1.XMLSerializer; | ||
//# sourceMappingURL=index.js.map |
@@ -6,3 +6,8 @@ import { Document } from "../dom/interfaces"; | ||
export declare class DOMParser { | ||
private algo; | ||
/** | ||
* Initializes a new instance of `DOMParser`. | ||
*/ | ||
constructor(); | ||
/** | ||
* Parses the given string and returns a document object. | ||
@@ -18,8 +23,2 @@ * | ||
*/ | ||
export declare enum MimeType { | ||
HTML = "text/html", | ||
TextXML = "text/xml", | ||
XML = "application/xml", | ||
XHTML = "application/xhtml+xml", | ||
SVG = "image/svg+xml" | ||
} | ||
export declare type MimeType = 'text/html' | 'text/xml' | 'application/xml' | 'application/xhtml+xml' | 'image/svg+xml'; |
@@ -13,2 +13,8 @@ "use strict"; | ||
/** | ||
* Initializes a new instance of `DOMParser`. | ||
*/ | ||
constructor() { | ||
this.algo = util_1.globalStore.dom.algorithm; | ||
} | ||
/** | ||
* Parses the given string and returns a document object. | ||
@@ -20,3 +26,3 @@ * | ||
parseFromString(source, mimeType) { | ||
if (mimeType === MimeType.HTML) { | ||
if (mimeType === "text/html") { | ||
throw new Error('HTML parser not implemented.'); | ||
@@ -26,5 +32,4 @@ } | ||
const lexer = new XMLStringLexer_1.XMLStringLexer(source); | ||
const algo = util_1.globalStore.algorithm; | ||
lexer.skipWhitespaceOnlyText = true; | ||
const doc = algo.create.document(); | ||
const doc = this.algo.create.document(); | ||
doc._contentType = mimeType; | ||
@@ -60,3 +65,3 @@ let context = doc; | ||
// inherit namespace from parent | ||
const [prefix, localName] = algo.namespace.extractQName(element.name); | ||
const [prefix, localName] = this.algo.namespace.extractQName(element.name); | ||
let namespace = context.lookupNamespaceURI(prefix); | ||
@@ -70,3 +75,3 @@ // override namespace if there is a namespace declaration | ||
else { | ||
const [attPrefix, attLocalName] = algo.namespace.extractQName(attName); | ||
const [attPrefix, attLocalName] = this.algo.namespace.extractQName(attName); | ||
if (attPrefix === "xmlns" && attLocalName === prefix) { | ||
@@ -88,3 +93,3 @@ namespace = attValue; | ||
} | ||
const [attPrefix, attLocalName] = algo.namespace.extractQName(attName); | ||
const [attPrefix, attLocalName] = this.algo.namespace.extractQName(attName); | ||
if (attPrefix === "xmlns") { | ||
@@ -113,4 +118,4 @@ // prefixed namespace declaration attribute | ||
} | ||
if (context.parentNode) { | ||
context = context.parentNode; | ||
if (context._parent) { | ||
context = context._parent; | ||
} | ||
@@ -125,13 +130,2 @@ break; | ||
exports.DOMParser = DOMParser; | ||
/** | ||
* Defines the mime type of the document. | ||
*/ | ||
var MimeType; | ||
(function (MimeType) { | ||
MimeType["HTML"] = "text/html"; | ||
MimeType["TextXML"] = "text/xml"; | ||
MimeType["XML"] = "application/xml"; | ||
MimeType["XHTML"] = "application/xhtml+xml"; | ||
MimeType["SVG"] = "image/svg+xml"; | ||
})(MimeType = exports.MimeType || (exports.MimeType = {})); | ||
//# sourceMappingURL=DOMParser.js.map |
@@ -1,3 +0,1 @@ | ||
export { DOMParser, MimeType } from './DOMParser'; | ||
import * as Interfaces from './interfaces'; | ||
export { Interfaces }; | ||
export { DOMParser } from './DOMParser'; |
"use strict"; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -13,6 +6,2 @@ // Export classes | ||
exports.DOMParser = DOMParser_1.DOMParser; | ||
exports.MimeType = DOMParser_1.MimeType; | ||
// Export interfaces | ||
const Interfaces = __importStar(require("./interfaces")); | ||
exports.Interfaces = Interfaces; | ||
//# sourceMappingURL=index.js.map |
@@ -110,3 +110,3 @@ import { XMLToken, XMLLexer } from './interfaces'; | ||
*/ | ||
[Symbol.iterator](): IterableIterator<XMLToken>; | ||
[Symbol.iterator](): Iterator<XMLToken>; | ||
} |
@@ -504,14 +504,15 @@ "use strict"; | ||
*/ | ||
*[Symbol.iterator]() { | ||
[Symbol.iterator]() { | ||
this.reset(); | ||
let flag = true; | ||
while (flag) { | ||
const token = this.nextToken(); | ||
if (token.type === interfaces_1.TokenType.EOF) { | ||
flag = false; | ||
} | ||
else { | ||
yield token; | ||
} | ||
} | ||
return { | ||
next: function () { | ||
const token = this.nextToken(); | ||
if (token.type === interfaces_1.TokenType.EOF) { | ||
return { done: true, value: null }; | ||
} | ||
else { | ||
return { done: false, value: token }; | ||
} | ||
}.bind(this) | ||
}; | ||
} | ||
@@ -518,0 +519,0 @@ } |
@@ -56,2 +56,3 @@ import { TokenType, XMLToken } from "./interfaces"; | ||
data: string; | ||
protected static WhiteSpace: RegExp; | ||
/** | ||
@@ -58,0 +59,0 @@ * Initializes a new instance of `CharacterDataToken`. |
@@ -78,5 +78,6 @@ "use strict"; | ||
get isWhitespace() { | ||
return !!this.data.match(/^[\t\n\f\r ]*$/); | ||
return CharacterDataToken.WhiteSpace.test(this.data); | ||
} | ||
} | ||
CharacterDataToken.WhiteSpace = /^[\t\n\f\r ]*$/; | ||
/** | ||
@@ -83,0 +84,0 @@ * Represents a comment token. |
export { XMLSerializerImpl as XMLSerializer } from './XMLSerializer'; | ||
export { PreSerializer } from './PreSerializer'; | ||
import * as Interfaces from './interfaces'; | ||
export { Interfaces }; |
"use strict"; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -13,7 +6,2 @@ // Export classes | ||
exports.XMLSerializer = XMLSerializer_1.XMLSerializerImpl; | ||
var PreSerializer_1 = require("./PreSerializer"); | ||
exports.PreSerializer = PreSerializer_1.PreSerializer; | ||
// Export interfaces | ||
const Interfaces = __importStar(require("./interfaces")); | ||
exports.Interfaces = Interfaces; | ||
//# sourceMappingURL=index.js.map |
@@ -20,3 +20,3 @@ "use strict"; | ||
this._xmlVersion = xmlVersion; | ||
this._algo = util_1.globalStore.algorithm; | ||
this._algo = util_1.globalStore.dom.algorithm; | ||
} | ||
@@ -66,3 +66,3 @@ /** | ||
catch (_a) { | ||
throw DOMException_1.DOMException.InvalidStateError; | ||
throw new DOMException_1.InvalidStateError(); | ||
} | ||
@@ -396,3 +396,3 @@ } | ||
*/ | ||
for (const childNode of node.childNodes) { | ||
for (const childNode of node._children) { | ||
children.push(this._serializeNode(childNode, inheritedNS, map, prefixIndex, requireWellFormed, level + 1)); | ||
@@ -450,3 +450,3 @@ } | ||
const children = []; | ||
for (const childNode of node.childNodes) { | ||
for (const childNode of node._children) { | ||
children.push(this._serializeNode(childNode, namespace, prefixMap, prefixIndex, requireWellFormed, level)); | ||
@@ -546,3 +546,3 @@ } | ||
const children = []; | ||
for (const childNode of node.childNodes) { | ||
for (const childNode of node._children) { | ||
children.push(this._serializeNode(childNode, namespace, prefixMap, prefixIndex, requireWellFormed, level)); | ||
@@ -549,0 +549,0 @@ } |
@@ -1,4 +0,2 @@ | ||
import { Window, Node } from "../dom/interfaces"; | ||
import { DOMAlgorithm } from "../algorithm/interfaces"; | ||
import { CompareCache } from "@oozcitak/util"; | ||
import { DOM } from "../dom/interfaces"; | ||
/** | ||
@@ -9,5 +7,3 @@ * Represents a global data store. | ||
private static _instance; | ||
private _algorithm; | ||
private _window; | ||
private _compareCache; | ||
private _dom; | ||
/** | ||
@@ -18,17 +14,7 @@ * Initializes a new instance of `GlobalStore`. | ||
/** | ||
* Gets or sets the DOM algorithm. | ||
* Gets or sets the DOM container class. | ||
*/ | ||
get algorithm(): DOMAlgorithm; | ||
set algorithm(val: DOMAlgorithm); | ||
get dom(): DOM; | ||
set dom(val: DOM); | ||
/** | ||
* Gets or sets the global window object. | ||
*/ | ||
get window(): Window; | ||
set window(val: Window); | ||
/** | ||
* Gets or sets the global window object. | ||
*/ | ||
get compareCache(): CompareCache<Node>; | ||
set compareCache(val: CompareCache<Node>); | ||
/** | ||
* Returns the instance of `GlobalStore`. | ||
@@ -35,0 +21,0 @@ */ |
@@ -11,37 +11,16 @@ "use strict"; | ||
constructor() { | ||
this._algorithm = null; | ||
this._window = null; | ||
this._compareCache = null; | ||
this._dom = null; | ||
} | ||
/** | ||
* Gets or sets the DOM algorithm. | ||
* Gets or sets the DOM container class. | ||
*/ | ||
get algorithm() { | ||
if (this._algorithm === null) { | ||
throw new Error("DOM algorithm instance is null."); | ||
get dom() { | ||
/* istanbul ignore next */ | ||
if (this._dom === null) { | ||
throw new Error("DOM container class instance is null."); | ||
} | ||
return this._algorithm; | ||
return this._dom; | ||
} | ||
set algorithm(val) { this._algorithm = val; } | ||
set dom(val) { this._dom = val; } | ||
/** | ||
* Gets or sets the global window object. | ||
*/ | ||
get window() { | ||
if (this._window === null) { | ||
throw new Error("Global window instance is null."); | ||
} | ||
return this._window; | ||
} | ||
set window(val) { this._window = val; } | ||
/** | ||
* Gets or sets the global window object. | ||
*/ | ||
get compareCache() { | ||
if (this._compareCache === null) { | ||
throw new Error("Global compare cache instance is null."); | ||
} | ||
return this._compareCache; | ||
} | ||
set compareCache(val) { this._compareCache = val; } | ||
/** | ||
* Returns the instance of `GlobalStore`. | ||
@@ -48,0 +27,0 @@ */ |
import { GlobalStore } from './GlobalStore'; | ||
export { GlobalStore }; | ||
export { Cast } from './Cast'; | ||
@@ -4,0 +3,0 @@ export { Guard } from './Guard'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const GlobalStore_1 = require("./GlobalStore"); | ||
exports.GlobalStore = GlobalStore_1.GlobalStore; | ||
var Cast_1 = require("./Cast"); | ||
@@ -6,0 +5,0 @@ exports.Cast = Cast_1.Cast; |
{ | ||
"name": "@oozcitak/dom", | ||
"version": "0.0.12", | ||
"version": "1.0.0", | ||
"keywords": [ | ||
@@ -33,10 +33,19 @@ "dom", | ||
"devDependencies": { | ||
"typescript": "*", | ||
"@types/dedent": "*", | ||
"@types/jest": "*", | ||
"@types/node": "*", | ||
"@types/xmldom": "*", | ||
"@types/jsdom": "*", | ||
"@types/benchmark": "*", | ||
"@types/chalk": "*", | ||
"dedent": "*", | ||
"glob": "*", | ||
"jest": "*", | ||
"jsdom": "*", | ||
"ts-jest": "*", | ||
"dedent": "*", | ||
"glob": "*", | ||
"@types/node": "*", | ||
"@types/jest": "*", | ||
"@types/dedent": "*" | ||
"typescript": "*", | ||
"xmldom": "*", | ||
"benchmark": "*", | ||
"ts-node": "*", | ||
"chalk": "*" | ||
}, | ||
@@ -56,4 +65,6 @@ "jest": { | ||
"test": "npm run compile && jest --coverage", | ||
"perf": "ts-node ./perf/perf.ts", | ||
"prof": "npm run compile && rm -f isolate-*-v8.log && node --prof ./perf/prof.js && find . -name isolate-*-v8.log -exec mv {} isolate-v8.log ; && node --prof-process isolate-v8.log > isolate.log && rm isolate-v8.log", | ||
"publish-public": "npm run test && npm publish --access public" | ||
} | ||
} |
@@ -5,10 +5,10 @@ # DOM | ||
[![License](http://img.shields.io/npm/l/@oozcitak/dom.svg?style=flat-square)](http://opensource.org/licenses/MIT) | ||
[![NPM Version](http://img.shields.io/npm/v/@oozcitak/dom.svg?style=flat-square)](https://www.npmjs.com/package/@oozcitak/dom) | ||
[![NPM Version](https://img.shields.io/npm/v/@oozcitak/dom?logo=npm&style=flat-square)](https://www.npmjs.com/package/@oozcitak/dom) | ||
[![Travis Build Status](http://img.shields.io/travis/oozcitak/dom.svg?style=flat-square)](http://travis-ci.org/oozcitak/dom) | ||
[![AppVeyor Build status](https://ci.appveyor.com/api/projects/status/j0oai7effi49w2rf?svg=true)](https://ci.appveyor.com/project/oozcitak/dom) | ||
[![Travis Build Status](https://img.shields.io/travis/oozcitak/dom?logo=travis&style=flat-square](http://travis-ci.org/oozcitak/dom) | ||
[![AppVeyor Build status](https://img.shields.io/appveyor/ci/oozcitak/dom?logo=appveyor&style=flat-square)](https://ci.appveyor.com/project/oozcitak/dom) | ||
[![Dev Dependency Status](http://img.shields.io/david/dev/oozcitak/dom.svg?style=flat-square)](https://david-dm.org/oozcitak/dom) | ||
[![Code Coverage](https://img.shields.io/codecov/c/github/oozcitak/dom?style=flat-square)](https://codecov.io/gh/oozcitak/dom) | ||
[![Code Coverage](https://img.shields.io/codecov/c/github/oozcitak/dom?logo=codecov&style=flat-square)](https://codecov.io/gh/oozcitak/dom) | ||
# Version | ||
Current version implements the standard as of commit [57512fa](https://dom.spec.whatwg.org/commit-snapshots/57512fac17cf2f1c4c85be4aec178c8086ee5ee4/). |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1101426
21752
0
17