@oozcitak/dom
Advanced tools
Comparing version 1.1.1 to 1.2.1
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const __1 = require("../"); | ||
const dom_1 = require("../dom"); | ||
const util_1 = require("../util"); | ||
@@ -36,3 +36,3 @@ const DOMException_1 = require("../dom/DOMException"); | ||
*/ | ||
if (__1.dom.features.mutationObservers) { | ||
if (dom_1.dom.features.mutationObservers) { | ||
MutationObserverAlgorithm_1.observer_queueMutationRecord("characterData", node, null, null, node.data, [], [], null, null); | ||
@@ -63,3 +63,3 @@ } | ||
*/ | ||
__1.dom.rangeList.forEach(range => { | ||
dom_1.dom.rangeList.forEach(range => { | ||
if (range._start[0] === node && range._start[1] > offset && range._start[1] <= offset + count) { | ||
@@ -82,3 +82,3 @@ range._start[1] += offset; | ||
*/ | ||
if (__1.dom.features.steps) { | ||
if (dom_1.dom.features.steps) { | ||
if (util_1.Guard.isTextNode(node) && node._parent !== null) { | ||
@@ -85,0 +85,0 @@ DOMAlgorithm_1.dom_runChildTextContentChangeSteps(node._parent); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const __1 = require("../"); | ||
const dom_1 = require("../dom"); | ||
const util_1 = require("../util"); | ||
const util_2 = require("@oozcitak/util"); | ||
const dom_1 = require("../dom"); | ||
const ElementImpl_1 = require("../dom/ElementImpl"); | ||
const CustomElementAlgorithm_1 = require("./CustomElementAlgorithm"); | ||
@@ -20,3 +20,3 @@ const TreeAlgorithm_1 = require("./TreeAlgorithm"); | ||
function document_elementInterface(name, namespace) { | ||
return dom_1.Element; | ||
return ElementImpl_1.ElementImpl; | ||
} | ||
@@ -99,3 +99,3 @@ exports.document_elementInterface = document_elementInterface; | ||
*/ | ||
if (__1.dom.features.customElements) { | ||
if (dom_1.dom.features.customElements) { | ||
if (util_1.Guard.isElementNode(inclusiveDescendant) && | ||
@@ -111,3 +111,3 @@ inclusiveDescendant._customElementState === "custom") { | ||
*/ | ||
if (__1.dom.features.steps) { | ||
if (dom_1.dom.features.steps) { | ||
DOMAlgorithm_1.dom_runAdoptingSteps(inclusiveDescendant, oldDocument); | ||
@@ -114,0 +114,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const __1 = require("../"); | ||
const dom_1 = require("../dom"); | ||
const TreeAlgorithm_1 = require("./TreeAlgorithm"); | ||
@@ -51,3 +51,3 @@ const util_1 = require("../util"); | ||
// run default steps | ||
if (__1.dom.features.slots) { | ||
if (dom_1.dom.features.slots) { | ||
updateASlotablesName.call(element, element, localName, oldValue, value, namespace); | ||
@@ -54,0 +54,0 @@ updateASlotsName.call(element, element, localName, oldValue, value, namespace); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const __1 = require("../"); | ||
const dom_1 = require("../dom"); | ||
const infra_1 = require("@oozcitak/infra"); | ||
@@ -39,3 +39,3 @@ const util_1 = require("../util"); | ||
*/ | ||
if (__1.dom.features.mutationObservers) { | ||
if (dom_1.dom.features.mutationObservers) { | ||
MutationObserverAlgorithm_1.observer_queueAttributeMutationRecord(element, attribute._localName, attribute._namespace, attribute._value); | ||
@@ -49,3 +49,3 @@ } | ||
*/ | ||
if (__1.dom.features.customElements) { | ||
if (dom_1.dom.features.customElements) { | ||
if (util_1.Guard.isCustomElementNode(element)) { | ||
@@ -60,3 +60,3 @@ CustomElementAlgorithm_1.customElement_enqueueACustomElementCallbackReaction(element, "attributeChangedCallback", [attribute._localName, attribute._value, value, attribute._namespace]); | ||
*/ | ||
if (__1.dom.features.steps) { | ||
if (dom_1.dom.features.steps) { | ||
DOMAlgorithm_1.dom_runAttributeChangeSteps(element, attribute._localName, attribute._value, value, attribute._namespace); | ||
@@ -78,3 +78,3 @@ } | ||
*/ | ||
if (__1.dom.features.mutationObservers) { | ||
if (dom_1.dom.features.mutationObservers) { | ||
MutationObserverAlgorithm_1.observer_queueAttributeMutationRecord(element, attribute._localName, attribute._namespace, null); | ||
@@ -88,3 +88,3 @@ } | ||
*/ | ||
if (__1.dom.features.customElements) { | ||
if (dom_1.dom.features.customElements) { | ||
if (util_1.Guard.isCustomElementNode(element)) { | ||
@@ -98,3 +98,3 @@ CustomElementAlgorithm_1.customElement_enqueueACustomElementCallbackReaction(element, "attributeChangedCallback", [attribute._localName, null, attribute._value, attribute._namespace]); | ||
*/ | ||
if (__1.dom.features.steps) { | ||
if (dom_1.dom.features.steps) { | ||
DOMAlgorithm_1.dom_runAttributeChangeSteps(element, attribute.localName, null, attribute._value, attribute._namespace); | ||
@@ -121,3 +121,3 @@ } | ||
*/ | ||
if (__1.dom.features.mutationObservers) { | ||
if (dom_1.dom.features.mutationObservers) { | ||
MutationObserverAlgorithm_1.observer_queueAttributeMutationRecord(element, attribute._localName, attribute._namespace, attribute._value); | ||
@@ -131,3 +131,3 @@ } | ||
*/ | ||
if (__1.dom.features.customElements) { | ||
if (dom_1.dom.features.customElements) { | ||
if (util_1.Guard.isCustomElementNode(element)) { | ||
@@ -141,3 +141,3 @@ CustomElementAlgorithm_1.customElement_enqueueACustomElementCallbackReaction(element, "attributeChangedCallback", [attribute._localName, attribute._value, null, attribute._namespace]); | ||
*/ | ||
if (__1.dom.features.steps) { | ||
if (dom_1.dom.features.steps) { | ||
DOMAlgorithm_1.dom_runAttributeChangeSteps(element, attribute.localName, attribute._value, null, attribute._namespace); | ||
@@ -166,3 +166,3 @@ } | ||
*/ | ||
if (__1.dom.features.mutationObservers) { | ||
if (dom_1.dom.features.mutationObservers) { | ||
MutationObserverAlgorithm_1.observer_queueAttributeMutationRecord(element, oldAttr._localName, oldAttr._namespace, oldAttr._value); | ||
@@ -176,3 +176,3 @@ } | ||
*/ | ||
if (__1.dom.features.customElements) { | ||
if (dom_1.dom.features.customElements) { | ||
if (util_1.Guard.isCustomElementNode(element)) { | ||
@@ -186,3 +186,3 @@ CustomElementAlgorithm_1.customElement_enqueueACustomElementCallbackReaction(element, "attributeChangedCallback", [oldAttr._localName, oldAttr._value, newAttr._value, oldAttr._namespace]); | ||
*/ | ||
if (__1.dom.features.steps) { | ||
if (dom_1.dom.features.steps) { | ||
DOMAlgorithm_1.dom_runAttributeChangeSteps(element, oldAttr.localName, oldAttr._value, newAttr._value, oldAttr._namespace); | ||
@@ -387,3 +387,3 @@ } | ||
let result = null; | ||
if (!__1.dom.features.customElements) { | ||
if (!dom_1.dom.features.customElements) { | ||
result = CreateAlgorithm_1.create_element(document, localName, namespace, prefix); | ||
@@ -390,0 +390,0 @@ result._customElementState = "uncustomized"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const __1 = require("../"); | ||
const dom_1 = require("../dom"); | ||
const interfaces_1 = require("../dom/interfaces"); | ||
@@ -99,3 +99,3 @@ const util_1 = require("../util"); | ||
Object.assign(event, dictionary); | ||
if (__1.dom.features.steps) { | ||
if (dom_1.dom.features.steps) { | ||
DOMAlgorithm_1.dom_runEventConstructingSteps(event); | ||
@@ -102,0 +102,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const __1 = require("../"); | ||
const dom_1 = require("../dom"); | ||
const DOMException_1 = require("../dom/DOMException"); | ||
@@ -215,5 +215,5 @@ const interfaces_1 = require("../dom/interfaces"); | ||
*/ | ||
if (__1.dom.rangeList.length !== 0) { | ||
if (dom_1.dom.rangeList.size !== 0) { | ||
const index = TreeAlgorithm_1.tree_index(child); | ||
__1.dom.rangeList.forEach(range => { | ||
dom_1.dom.rangeList.forEach(range => { | ||
if (range._start[0] === parent && range._start[1] > index) { | ||
@@ -247,3 +247,3 @@ range._start[1] += count; | ||
*/ | ||
if (__1.dom.features.mutationObservers) { | ||
if (dom_1.dom.features.mutationObservers) { | ||
if (node.nodeType === interfaces_1.NodeType.DocumentFragment) { | ||
@@ -302,3 +302,3 @@ MutationObserverAlgorithm_1.observer_queueTreeMutationRecord(node, [], nodes, null, null); | ||
*/ | ||
if (__1.dom.features.slots) { | ||
if (dom_1.dom.features.slots) { | ||
if (parent._shadowRoot !== null && util_1.Guard.isSlotable(node)) { | ||
@@ -312,3 +312,3 @@ ShadowTreeAlgorithm_1.shadowTree_assignASlot(node); | ||
*/ | ||
if (__1.dom.features.steps) { | ||
if (dom_1.dom.features.steps) { | ||
if (util_1.Guard.isTextNode(node)) { | ||
@@ -323,3 +323,3 @@ DOMAlgorithm_1.dom_runChildTextContentChangeSteps(parent); | ||
*/ | ||
if (__1.dom.features.slots) { | ||
if (dom_1.dom.features.slots) { | ||
if (util_1.Guard.isShadowRoot(TreeAlgorithm_1.tree_rootNode(parent)) && | ||
@@ -333,3 +333,3 @@ util_1.Guard.isSlot(parent) && util_2.isEmpty(parent._assignedNodes)) { | ||
*/ | ||
if (__1.dom.features.slots) { | ||
if (dom_1.dom.features.slots) { | ||
ShadowTreeAlgorithm_1.shadowTree_assignSlotablesForATree(TreeAlgorithm_1.tree_rootNode(node)); | ||
@@ -347,6 +347,6 @@ } | ||
*/ | ||
if (__1.dom.features.steps) { | ||
if (dom_1.dom.features.steps) { | ||
DOMAlgorithm_1.dom_runInsertionSteps(inclusiveDescendant); | ||
} | ||
if (__1.dom.features.customElements) { | ||
if (dom_1.dom.features.customElements) { | ||
/** | ||
@@ -380,3 +380,3 @@ * 7.7.2. If inclusiveDescendant is connected, then: | ||
*/ | ||
if (__1.dom.features.mutationObservers) { | ||
if (dom_1.dom.features.mutationObservers) { | ||
if (!suppressObservers) { | ||
@@ -448,3 +448,3 @@ MutationObserverAlgorithm_1.observer_queueTreeMutationRecord(parent, nodes, [], previousSibling, child); | ||
*/ | ||
if (__1.dom.features.slots) { | ||
if (dom_1.dom.features.slots) { | ||
if (parent._shadowRoot !== null && util_1.Guard.isSlotable(node)) { | ||
@@ -458,3 +458,3 @@ ShadowTreeAlgorithm_1.shadowTree_assignASlot(node); | ||
*/ | ||
if (__1.dom.features.steps) { | ||
if (dom_1.dom.features.steps) { | ||
if (util_1.Guard.isTextNode(node)) { | ||
@@ -469,3 +469,3 @@ DOMAlgorithm_1.dom_runChildTextContentChangeSteps(parent); | ||
*/ | ||
if (__1.dom.features.slots) { | ||
if (dom_1.dom.features.slots) { | ||
if (util_1.Guard.isShadowRoot(TreeAlgorithm_1.tree_rootNode(parent)) && | ||
@@ -479,3 +479,3 @@ util_1.Guard.isSlot(parent) && util_2.isEmpty(parent._assignedNodes)) { | ||
*/ | ||
if (__1.dom.features.slots) { | ||
if (dom_1.dom.features.slots) { | ||
ShadowTreeAlgorithm_1.shadowTree_assignSlotablesForATree(TreeAlgorithm_1.tree_rootNode(node)); | ||
@@ -489,6 +489,6 @@ } | ||
*/ | ||
if (__1.dom.features.steps) { | ||
if (dom_1.dom.features.steps) { | ||
DOMAlgorithm_1.dom_runInsertionSteps(node); | ||
} | ||
if (__1.dom.features.customElements) { | ||
if (dom_1.dom.features.customElements) { | ||
/** | ||
@@ -519,3 +519,3 @@ * 7.7.2. If inclusiveDescendant is connected, then: | ||
*/ | ||
if (__1.dom.features.mutationObservers) { | ||
if (dom_1.dom.features.mutationObservers) { | ||
if (!suppressObservers) { | ||
@@ -702,3 +702,3 @@ MutationObserverAlgorithm_1.observer_queueTreeMutationRecord(parent, [node], [], previousSibling, null); | ||
*/ | ||
if (__1.dom.features.mutationObservers) { | ||
if (dom_1.dom.features.mutationObservers) { | ||
MutationObserverAlgorithm_1.observer_queueTreeMutationRecord(parent, nodes, removedNodes, previousSibling, referenceChild); | ||
@@ -758,3 +758,3 @@ } | ||
*/ | ||
if (__1.dom.features.mutationObservers) { | ||
if (dom_1.dom.features.mutationObservers) { | ||
MutationObserverAlgorithm_1.observer_queueTreeMutationRecord(parent, addedNodes, removedNodes, null, null); | ||
@@ -792,3 +792,3 @@ } | ||
function mutation_remove(node, parent, suppressObservers) { | ||
if (__1.dom.rangeList.length !== 0) { | ||
if (dom_1.dom.rangeList.size !== 0) { | ||
/** | ||
@@ -804,3 +804,3 @@ * 1. Let index be node’s index. | ||
*/ | ||
__1.dom.rangeList.forEach(range => { | ||
dom_1.dom.rangeList.forEach(range => { | ||
if (TreeAlgorithm_1.tree_isDescendantOf(node, range._start[0], true)) { | ||
@@ -825,3 +825,3 @@ range._start = [parent, index]; | ||
*/ | ||
__1.dom.rangeList.forEach(range => { | ||
dom_1.dom.rangeList.forEach(range => { | ||
if (range._start[0] === parent && range._start[1] > index) { | ||
@@ -840,3 +840,3 @@ range._start[1] -= 1; | ||
*/ | ||
if (__1.dom.features.steps) { | ||
if (dom_1.dom.features.steps) { | ||
NodeIteratorAlgorithm_1.nodeIterator_iteratorList().forEach(iterator => { | ||
@@ -876,3 +876,3 @@ if (iterator._root._nodeDocument === node._nodeDocument) { | ||
*/ | ||
if (__1.dom.features.slots) { | ||
if (dom_1.dom.features.slots) { | ||
if (util_1.Guard.isSlotable(node) && node._assignedSlot !== null && ShadowTreeAlgorithm_1.shadowTree_isAssigned(node)) { | ||
@@ -887,3 +887,3 @@ ShadowTreeAlgorithm_1.shadowTree_assignSlotables(node._assignedSlot); | ||
*/ | ||
if (__1.dom.features.slots) { | ||
if (dom_1.dom.features.slots) { | ||
if (util_1.Guard.isShadowRoot(TreeAlgorithm_1.tree_rootNode(parent)) && | ||
@@ -899,3 +899,3 @@ util_1.Guard.isSlot(parent) && util_2.isEmpty(parent._assignedNodes)) { | ||
*/ | ||
if (__1.dom.features.slots) { | ||
if (dom_1.dom.features.slots) { | ||
const descendant = TreeAlgorithm_1.tree_getFirstDescendantNode(node, true, false, (e) => util_1.Guard.isSlot(e)); | ||
@@ -910,3 +910,3 @@ if (descendant !== null) { | ||
*/ | ||
if (__1.dom.features.steps) { | ||
if (dom_1.dom.features.steps) { | ||
DOMAlgorithm_1.dom_runRemovingSteps(node, parent); | ||
@@ -919,3 +919,3 @@ } | ||
*/ | ||
if (__1.dom.features.customElements) { | ||
if (dom_1.dom.features.customElements) { | ||
if (util_1.Guard.isCustomElementNode(node)) { | ||
@@ -934,3 +934,3 @@ CustomElementAlgorithm_1.customElement_enqueueACustomElementCallbackReaction(node, "disconnectedCallback", []); | ||
*/ | ||
if (__1.dom.features.steps) { | ||
if (dom_1.dom.features.steps) { | ||
DOMAlgorithm_1.dom_runRemovingSteps(descendant, node); | ||
@@ -943,3 +943,3 @@ } | ||
*/ | ||
if (__1.dom.features.customElements) { | ||
if (dom_1.dom.features.customElements) { | ||
if (util_1.Guard.isCustomElementNode(descendant)) { | ||
@@ -960,3 +960,3 @@ CustomElementAlgorithm_1.customElement_enqueueACustomElementCallbackReaction(descendant, "disconnectedCallback", []); | ||
*/ | ||
if (__1.dom.features.mutationObservers) { | ||
if (dom_1.dom.features.mutationObservers) { | ||
let inclusiveAncestor = TreeAlgorithm_1.tree_getFirstAncestorNode(parent, true); | ||
@@ -981,3 +981,3 @@ while (inclusiveAncestor !== null) { | ||
*/ | ||
if (__1.dom.features.mutationObservers) { | ||
if (dom_1.dom.features.mutationObservers) { | ||
if (!suppressObservers) { | ||
@@ -991,3 +991,3 @@ MutationObserverAlgorithm_1.observer_queueTreeMutationRecord(parent, [], [node], oldPreviousSibling, oldNextSibling); | ||
*/ | ||
if (__1.dom.features.steps) { | ||
if (dom_1.dom.features.steps) { | ||
if (util_1.Guard.isTextNode(node)) { | ||
@@ -994,0 +994,0 @@ DOMAlgorithm_1.dom_runChildTextContentChangeSteps(parent); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const __1 = require("../"); | ||
const dom_1 = require("../dom"); | ||
const util_1 = require("../util"); | ||
@@ -20,3 +20,3 @@ const infra_1 = require("@oozcitak/infra"); | ||
*/ | ||
const window = __1.dom.window; | ||
const window = dom_1.dom.window; | ||
if (window._mutationObserverMicrotaskQueued) | ||
@@ -38,3 +38,3 @@ return; | ||
*/ | ||
const window = __1.dom.window; | ||
const window = dom_1.dom.window; | ||
window._mutationObserverMicrotaskQueued = false; | ||
@@ -81,3 +81,3 @@ const notifySet = infra_1.set.clone(window._mutationObservers); | ||
*/ | ||
if (__1.dom.features.slots) { | ||
if (dom_1.dom.features.slots) { | ||
signalSet.forEach(slot => EventAlgorithm_1.event_fireAnEvent("slotchange", slot, undefined, { bubbles: true })); | ||
@@ -84,0 +84,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const __1 = require("../"); | ||
const dom_1 = require("../dom"); | ||
const util_1 = require("../util"); | ||
@@ -136,3 +136,3 @@ const infra_1 = require("@oozcitak/infra"); | ||
*/ | ||
if (__1.dom.features.steps) { | ||
if (dom_1.dom.features.steps) { | ||
DOMAlgorithm_1.dom_runCloningSteps(copy, node, document, cloneChildrenFlag); | ||
@@ -139,0 +139,0 @@ } |
import { Node, NodeIterator } from "../dom/interfaces"; | ||
import { ObjectCache } from "@oozcitak/util"; | ||
import { FixedSizeSet } from "@oozcitak/util"; | ||
/** | ||
@@ -15,2 +15,2 @@ * Returns the next or previous node in the subtree, or `null` if | ||
*/ | ||
export declare function nodeIterator_iteratorList(): ObjectCache<NodeIterator>; | ||
export declare function nodeIterator_iteratorList(): FixedSizeSet<NodeIterator>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const __1 = require("../"); | ||
const dom_1 = require("../dom"); | ||
const interfaces_1 = require("../dom/interfaces"); | ||
@@ -102,5 +102,5 @@ const TraversalAlgorithm_1 = require("./TraversalAlgorithm"); | ||
function nodeIterator_iteratorList() { | ||
return __1.dom.window._iteratorList; | ||
return dom_1.dom.window._iteratorList; | ||
} | ||
exports.nodeIterator_iteratorList = nodeIterator_iteratorList; | ||
//# sourceMappingURL=NodeIteratorAlgorithm.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const __1 = require("../"); | ||
const dom_1 = require("../dom"); | ||
const util_1 = require("../util"); | ||
@@ -18,3 +18,3 @@ const util_2 = require("@oozcitak/util"); | ||
*/ | ||
const window = __1.dom.window; | ||
const window = dom_1.dom.window; | ||
window._signalSlots.add(slot); | ||
@@ -21,0 +21,0 @@ MutationObserverAlgorithm_1.observer_queueAMutationObserverMicrotask(); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const __1 = require("../"); | ||
const dom_1 = require("../dom"); | ||
const util_1 = require("../util"); | ||
@@ -173,3 +173,3 @@ const DOMException_1 = require("../dom/DOMException"); | ||
*/ | ||
__1.dom.rangeList.forEach(range => { | ||
dom_1.dom.rangeList.forEach(range => { | ||
if (range._start[0] === node && range._start[1] > offset) { | ||
@@ -176,0 +176,0 @@ range._start[0] = newNode; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const DOMImpl_1 = require("../dom/DOMImpl"); | ||
const dom_1 = require("../dom"); | ||
/** | ||
@@ -10,3 +10,3 @@ * Determines if the given string is valid for a `"Name"` construct. | ||
function xml_isName(name) { | ||
return DOMImpl_1.DOMImpl.instance.regExp.Name.value.test(name); | ||
return dom_1.dom.regExp.Name.value.test(name); | ||
} | ||
@@ -20,3 +20,3 @@ exports.xml_isName = xml_isName; | ||
function xml_isQName(name) { | ||
return DOMImpl_1.DOMImpl.instance.regExp.QName.value.test(name); | ||
return dom_1.dom.regExp.QName.value.test(name); | ||
} | ||
@@ -32,6 +32,6 @@ exports.xml_isQName = xml_isQName; | ||
if (xmlVersion === "1.0") { | ||
return (!DOMImpl_1.DOMImpl.instance.regExp.InvalidChar_10.value.test(chars)); | ||
return (!dom_1.dom.regExp.InvalidChar_10.value.test(chars)); | ||
} | ||
else { | ||
return (!DOMImpl_1.DOMImpl.instance.regExp.InvalidChar_11.value.test(chars)); | ||
return (!dom_1.dom.regExp.InvalidChar_11.value.test(chars)); | ||
} | ||
@@ -47,5 +47,5 @@ } | ||
function xml_isPubidChar(chars) { | ||
return DOMImpl_1.DOMImpl.instance.regExp.PubidChar.value.test(chars); | ||
return dom_1.dom.regExp.PubidChar.value.test(chars); | ||
} | ||
exports.xml_isPubidChar = xml_isPubidChar; | ||
//# sourceMappingURL=XMLAlgorithm.js.map |
@@ -40,3 +40,3 @@ import { Element, NodeType, Attr, Document, Node } from "./interfaces"; | ||
/** | ||
* Creates a `Attr`. | ||
* Creates an `Attr`. | ||
* | ||
@@ -43,0 +43,0 @@ * @param document - owner document |
@@ -61,3 +61,3 @@ "use strict"; | ||
/** | ||
* Creates a `Attr`. | ||
* Creates an `Attr`. | ||
* | ||
@@ -64,0 +64,0 @@ * @param document - owner document |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const __1 = require("../"); | ||
const _1 = require("./"); | ||
const interfaces_1 = require("./interfaces"); | ||
@@ -381,3 +381,3 @@ const DOMException_1 = require("./DOMException"); | ||
else { | ||
return __1.dom.window; | ||
return _1.dom.window; | ||
} | ||
@@ -384,0 +384,0 @@ } |
import { DOMFeatures, Window, Node, Range } from "./interfaces"; | ||
import { CompareCache, ObjectCache, Lazy } from "@oozcitak/util"; | ||
import { CompareCache, FixedSizeSet, Lazy } from "@oozcitak/util"; | ||
declare type RegExpDict = { | ||
@@ -13,3 +13,3 @@ Name: Lazy<RegExp>; | ||
*/ | ||
export declare class DOMImpl { | ||
declare class DOMImpl { | ||
private static _instance; | ||
@@ -47,3 +47,3 @@ private _features; | ||
*/ | ||
get rangeList(): ObjectCache<Range>; | ||
get rangeList(): FixedSizeSet<Range>; | ||
/** | ||
@@ -58,2 +58,6 @@ * Gets the global RegExp list. | ||
} | ||
/** | ||
* Represents an object implementing DOM algorithms. | ||
*/ | ||
export declare const dom: DOMImpl; | ||
export {}; |
@@ -21,3 +21,3 @@ "use strict"; | ||
this._compareCache = new util_1.CompareCache(); | ||
this._rangeList = new util_1.ObjectCache(); | ||
this._rangeList = new util_1.FixedSizeSet(); | ||
this._regExp = { | ||
@@ -92,3 +92,6 @@ /** Matches a valid XML name */ | ||
} | ||
exports.DOMImpl = DOMImpl; | ||
/** | ||
* Represents an object implementing DOM algorithms. | ||
*/ | ||
exports.dom = DOMImpl.instance; | ||
//# sourceMappingURL=DOMImpl.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const _1 = require("./"); | ||
const infra_1 = require("@oozcitak/infra"); | ||
const algorithm_1 = require("../algorithm"); | ||
const DOMImpl_1 = require("./DOMImpl"); | ||
/** | ||
@@ -17,3 +17,3 @@ * Represents an object providing methods which are not dependent on | ||
constructor(document) { | ||
this._associatedDocument = document || DOMImpl_1.DOMImpl.instance.window.document; | ||
this._associatedDocument = document || _1.dom.window.document; | ||
} | ||
@@ -20,0 +20,0 @@ /** @inheritdoc */ |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const __1 = require("../"); | ||
const _1 = require("./"); | ||
const DOMException_1 = require("./DOMException"); | ||
@@ -49,3 +49,3 @@ const infra_1 = require("@oozcitak/infra"); | ||
this._element._attributeChangeSteps.push(updateTokenSet); | ||
if (__1.dom.features.steps) { | ||
if (_1.dom.features.steps) { | ||
algorithm_1.dom_runAttributeChangeSteps(element, localName, value, value, null); | ||
@@ -52,0 +52,0 @@ } |
@@ -16,4 +16,3 @@ import { Attr, NamedNodeMap, DOMTokenList, ShadowRoot, NodeType, Node, Document, Element, HTMLCollection, NodeList, ShadowRootMode, CustomElementDefinition, HTMLSlotElement, Slot, AttributeChangeStep } from "./interfaces"; | ||
_shadowRoot: ShadowRoot | null; | ||
__attributeList?: NamedNodeMap; | ||
get _attributeList(): NamedNodeMap; | ||
_attributeList: NamedNodeMap; | ||
_uniqueIdentifier?: string; | ||
@@ -20,0 +19,0 @@ _attributeChangeSteps: AttributeChangeStep[]; |
@@ -26,2 +26,3 @@ "use strict"; | ||
this._shadowRoot = null; | ||
this._attributeList = algorithm_1.create_namedNodeMap(this); | ||
this._attributeChangeSteps = []; | ||
@@ -31,3 +32,2 @@ this._name = ''; | ||
} | ||
get _attributeList() { return this.__attributeList || (this.__attributeList = algorithm_1.create_namedNodeMap(this)); } | ||
/** @inheritdoc */ | ||
@@ -34,0 +34,0 @@ get namespaceURI() { return this._namespace; } |
@@ -6,6 +6,6 @@ import { EventInit, EventTarget, EventPhase, PotentialEventTarget, EventPathItem, Event } from "./interfaces"; | ||
export declare class EventImpl implements Event { | ||
readonly NONE: number; | ||
readonly CAPTURING_PHASE: number; | ||
readonly AT_TARGET: number; | ||
readonly BUBBLING_PHASE: number; | ||
static NONE: number; | ||
static CAPTURING_PHASE: number; | ||
static AT_TARGET: number; | ||
static BUBBLING_PHASE: number; | ||
_target: PotentialEventTarget; | ||
@@ -12,0 +12,0 @@ _relatedTarget: PotentialEventTarget; |
@@ -13,6 +13,2 @@ "use strict"; | ||
constructor(type, eventInit) { | ||
this.NONE = 0; | ||
this.CAPTURING_PHASE = 1; | ||
this.AT_TARGET = 2; | ||
this.BUBBLING_PHASE = 3; | ||
this._target = null; | ||
@@ -251,2 +247,6 @@ this._relatedTarget = null; | ||
exports.EventImpl = EventImpl; | ||
EventImpl.NONE = 0; | ||
EventImpl.CAPTURING_PHASE = 1; | ||
EventImpl.AT_TARGET = 2; | ||
EventImpl.BUBBLING_PHASE = 3; | ||
//# sourceMappingURL=EventImpl.js.map |
@@ -12,3 +12,3 @@ import { AbortControllerImpl } from "./AbortControllerImpl"; | ||
import { DocumentTypeImpl } from "./DocumentTypeImpl"; | ||
import { DOMImpl } from "./DOMImpl"; | ||
import { dom } from "./DOMImpl"; | ||
import { DOMImplementationImpl } from "./DOMImplementationImpl"; | ||
@@ -37,2 +37,2 @@ import { DOMTokenListImpl } from "./DOMTokenListImpl"; | ||
import { XMLDocumentImpl } from "./XMLDocumentImpl"; | ||
export { AbortControllerImpl as AbortController, AbortSignalImpl as AbortSignal, AbstractRangeImpl as AbstractRange, AttrImpl as Attr, CDATASectionImpl as CDATASection, CharacterDataImpl as CharacterData, CommentImpl as Comment, CustomEventImpl as CustomEvent, DocumentFragmentImpl as DocumentFragment, DocumentImpl as Document, DocumentTypeImpl as DocumentType, DOMImpl as DOM, DOMImplementationImpl as DOMImplementation, DOMTokenListImpl as DOMTokenList, ElementImpl as Element, EventImpl as Event, EventTargetImpl as EventTarget, HTMLCollectionImpl as HTMLCollection, MutationObserverImpl as MutationObserver, MutationRecordImpl as MutationRecord, NamedNodeMapImpl as NamedNodeMap, NodeFilterImpl as NodeFilter, NodeImpl as Node, NodeIteratorImpl as NodeIterator, NodeListImpl as NodeList, NodeListStaticImpl as NodeListStatic, ProcessingInstructionImpl as ProcessingInstruction, RangeImpl as Range, ShadowRootImpl as ShadowRoot, StaticRangeImpl as StaticRange, TextImpl as Text, TraverserImpl as Traverser, TreeWalkerImpl as TreeWalker, WindowImpl as Window, XMLDocumentImpl as XMLDocument }; | ||
export { AbortControllerImpl as AbortController, AbortSignalImpl as AbortSignal, AbstractRangeImpl as AbstractRange, AttrImpl as Attr, CDATASectionImpl as CDATASection, CharacterDataImpl as CharacterData, CommentImpl as Comment, CustomEventImpl as CustomEvent, DocumentFragmentImpl as DocumentFragment, DocumentImpl as Document, DocumentTypeImpl as DocumentType, dom, DOMImplementationImpl as DOMImplementation, DOMTokenListImpl as DOMTokenList, ElementImpl as Element, EventImpl as Event, EventTargetImpl as EventTarget, HTMLCollectionImpl as HTMLCollection, MutationObserverImpl as MutationObserver, MutationRecordImpl as MutationRecord, NamedNodeMapImpl as NamedNodeMap, NodeFilterImpl as NodeFilter, NodeImpl as Node, NodeIteratorImpl as NodeIterator, NodeListImpl as NodeList, NodeListStaticImpl as NodeListStatic, ProcessingInstructionImpl as ProcessingInstruction, RangeImpl as Range, ShadowRootImpl as ShadowRoot, StaticRangeImpl as StaticRange, TextImpl as Text, TraverserImpl as Traverser, TreeWalkerImpl as TreeWalker, WindowImpl as Window, XMLDocumentImpl as XMLDocument }; |
@@ -30,3 +30,3 @@ "use strict"; | ||
const DOMImpl_1 = require("./DOMImpl"); | ||
exports.DOM = DOMImpl_1.DOMImpl; | ||
exports.dom = DOMImpl_1.dom; | ||
const DOMImplementationImpl_1 = require("./DOMImplementationImpl"); | ||
@@ -33,0 +33,0 @@ exports.DOMImplementation = DOMImplementationImpl_1.DOMImplementationImpl; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const __1 = require("../"); | ||
const _1 = require("./"); | ||
const util_1 = require("../util"); | ||
@@ -25,3 +25,3 @@ const infra_1 = require("@oozcitak/infra"); | ||
this._callback = callback; | ||
const window = __1.dom.window; | ||
const window = _1.dom.window; | ||
infra_1.set.append(window._mutationObservers, this); | ||
@@ -28,0 +28,0 @@ } |
@@ -6,18 +6,18 @@ import { Node, FilterResult, NodeFilter } from "./interfaces"; | ||
export declare class NodeFilterImpl implements NodeFilter { | ||
readonly FILTER_ACCEPT: number; | ||
readonly FILTER_REJECT: number; | ||
readonly FILTER_SKIP: number; | ||
readonly SHOW_ALL: number; | ||
readonly SHOW_ELEMENT: number; | ||
readonly SHOW_ATTRIBUTE: number; | ||
readonly SHOW_TEXT: number; | ||
readonly SHOW_CDATA_SECTION: number; | ||
readonly SHOW_ENTITY_REFERENCE: number; | ||
readonly SHOW_ENTITY: number; | ||
readonly SHOW_PROCESSING_INSTRUCTION: number; | ||
readonly SHOW_COMMENT: number; | ||
readonly SHOW_DOCUMENT: number; | ||
readonly SHOW_DOCUMENT_TYPE: number; | ||
readonly SHOW_DOCUMENT_FRAGMENT: number; | ||
readonly SHOW_NOTATION: number; | ||
static FILTER_ACCEPT: number; | ||
static FILTER_REJECT: number; | ||
static FILTER_SKIP: number; | ||
static SHOW_ALL: number; | ||
static SHOW_ELEMENT: number; | ||
static SHOW_ATTRIBUTE: number; | ||
static SHOW_TEXT: number; | ||
static SHOW_CDATA_SECTION: number; | ||
static SHOW_ENTITY_REFERENCE: number; | ||
static SHOW_ENTITY: number; | ||
static SHOW_PROCESSING_INSTRUCTION: number; | ||
static SHOW_COMMENT: number; | ||
static SHOW_DOCUMENT: number; | ||
static SHOW_DOCUMENT_TYPE: number; | ||
static SHOW_DOCUMENT_FRAGMENT: number; | ||
static SHOW_NOTATION: number; | ||
/** | ||
@@ -24,0 +24,0 @@ * Initializes a new instance of `NodeFilter`. |
@@ -12,18 +12,2 @@ "use strict"; | ||
constructor() { | ||
this.FILTER_ACCEPT = 1; | ||
this.FILTER_REJECT = 2; | ||
this.FILTER_SKIP = 3; | ||
this.SHOW_ALL = 0xffffffff; | ||
this.SHOW_ELEMENT = 0x1; | ||
this.SHOW_ATTRIBUTE = 0x2; | ||
this.SHOW_TEXT = 0x4; | ||
this.SHOW_CDATA_SECTION = 0x8; | ||
this.SHOW_ENTITY_REFERENCE = 0x10; | ||
this.SHOW_ENTITY = 0x20; | ||
this.SHOW_PROCESSING_INSTRUCTION = 0x40; | ||
this.SHOW_COMMENT = 0x80; | ||
this.SHOW_DOCUMENT = 0x100; | ||
this.SHOW_DOCUMENT_TYPE = 0x200; | ||
this.SHOW_DOCUMENT_FRAGMENT = 0x400; | ||
this.SHOW_NOTATION = 0x800; | ||
} | ||
@@ -44,2 +28,18 @@ /** | ||
exports.NodeFilterImpl = NodeFilterImpl; | ||
NodeFilterImpl.FILTER_ACCEPT = 1; | ||
NodeFilterImpl.FILTER_REJECT = 2; | ||
NodeFilterImpl.FILTER_SKIP = 3; | ||
NodeFilterImpl.SHOW_ALL = 0xffffffff; | ||
NodeFilterImpl.SHOW_ELEMENT = 0x1; | ||
NodeFilterImpl.SHOW_ATTRIBUTE = 0x2; | ||
NodeFilterImpl.SHOW_TEXT = 0x4; | ||
NodeFilterImpl.SHOW_CDATA_SECTION = 0x8; | ||
NodeFilterImpl.SHOW_ENTITY_REFERENCE = 0x10; | ||
NodeFilterImpl.SHOW_ENTITY = 0x20; | ||
NodeFilterImpl.SHOW_PROCESSING_INSTRUCTION = 0x40; | ||
NodeFilterImpl.SHOW_COMMENT = 0x80; | ||
NodeFilterImpl.SHOW_DOCUMENT = 0x100; | ||
NodeFilterImpl.SHOW_DOCUMENT_TYPE = 0x200; | ||
NodeFilterImpl.SHOW_DOCUMENT_FRAGMENT = 0x400; | ||
NodeFilterImpl.SHOW_NOTATION = 0x800; | ||
//# sourceMappingURL=NodeFilterImpl.js.map |
@@ -7,20 +7,20 @@ import { Node, NodeList, Element, Document, NodeType, Position, GetRootNodeOptions, RegisteredObserver, TransientRegisteredObserver, Event, EventTarget } from "./interfaces"; | ||
export declare abstract class NodeImpl extends EventTargetImpl implements Node { | ||
readonly ELEMENT_NODE: number; | ||
readonly ATTRIBUTE_NODE: number; | ||
readonly TEXT_NODE: number; | ||
readonly CDATA_SECTION_NODE: number; | ||
readonly ENTITY_REFERENCE_NODE: number; | ||
readonly ENTITY_NODE: number; | ||
readonly PROCESSING_INSTRUCTION_NODE: number; | ||
readonly COMMENT_NODE: number; | ||
readonly DOCUMENT_NODE: number; | ||
readonly DOCUMENT_TYPE_NODE: number; | ||
readonly DOCUMENT_FRAGMENT_NODE: number; | ||
readonly NOTATION_NODE: number; | ||
readonly DOCUMENT_POSITION_DISCONNECTED: number; | ||
readonly DOCUMENT_POSITION_PRECEDING: number; | ||
readonly DOCUMENT_POSITION_FOLLOWING: number; | ||
readonly DOCUMENT_POSITION_CONTAINS: number; | ||
readonly DOCUMENT_POSITION_CONTAINED_BY: number; | ||
readonly DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number; | ||
static ELEMENT_NODE: number; | ||
static ATTRIBUTE_NODE: number; | ||
static TEXT_NODE: number; | ||
static CDATA_SECTION_NODE: number; | ||
static ENTITY_REFERENCE_NODE: number; | ||
static ENTITY_NODE: number; | ||
static PROCESSING_INSTRUCTION_NODE: number; | ||
static COMMENT_NODE: number; | ||
static DOCUMENT_NODE: number; | ||
static DOCUMENT_TYPE_NODE: number; | ||
static DOCUMENT_FRAGMENT_NODE: number; | ||
static NOTATION_NODE: number; | ||
static DOCUMENT_POSITION_DISCONNECTED: number; | ||
static DOCUMENT_POSITION_PRECEDING: number; | ||
static DOCUMENT_POSITION_FOLLOWING: number; | ||
static DOCUMENT_POSITION_CONTAINS: number; | ||
static DOCUMENT_POSITION_CONTAINED_BY: number; | ||
static DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number; | ||
private __childNodes?; | ||
@@ -27,0 +27,0 @@ get _childNodes(): NodeList; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const __1 = require("../"); | ||
const _1 = require("./"); | ||
const interfaces_1 = require("./interfaces"); | ||
@@ -19,20 +19,2 @@ const EventTargetImpl_1 = require("./EventTargetImpl"); | ||
super(); | ||
this.ELEMENT_NODE = 1; | ||
this.ATTRIBUTE_NODE = 2; | ||
this.TEXT_NODE = 3; | ||
this.CDATA_SECTION_NODE = 4; | ||
this.ENTITY_REFERENCE_NODE = 5; | ||
this.ENTITY_NODE = 6; | ||
this.PROCESSING_INSTRUCTION_NODE = 7; | ||
this.COMMENT_NODE = 8; | ||
this.DOCUMENT_NODE = 9; | ||
this.DOCUMENT_TYPE_NODE = 10; | ||
this.DOCUMENT_FRAGMENT_NODE = 11; | ||
this.NOTATION_NODE = 12; | ||
this.DOCUMENT_POSITION_DISCONNECTED = 0x01; | ||
this.DOCUMENT_POSITION_PRECEDING = 0x02; | ||
this.DOCUMENT_POSITION_FOLLOWING = 0x04; | ||
this.DOCUMENT_POSITION_CONTAINS = 0x08; | ||
this.DOCUMENT_POSITION_CONTAINED_BY = 0x10; | ||
this.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20; | ||
this._parent = null; | ||
@@ -47,3 +29,3 @@ this._firstChild = null; | ||
} | ||
get _nodeDocument() { return this._nodeDocumentOverride || __1.dom.window._associatedDocument; } | ||
get _nodeDocument() { return this._nodeDocumentOverride || _1.dom.window._associatedDocument; } | ||
set _nodeDocument(val) { this._nodeDocumentOverride = val; } | ||
@@ -342,3 +324,3 @@ get _registeredObserverList() { | ||
*/ | ||
if (__1.dom.rangeList.length !== 0) { | ||
if (_1.dom.rangeList.size !== 0) { | ||
let currentNode = node._nextSibling; | ||
@@ -360,3 +342,3 @@ while (currentNode !== null && util_1.Guard.isExclusiveTextNode(currentNode)) { | ||
const index = algorithm_1.tree_index(cn); | ||
__1.dom.rangeList.forEach(range => { | ||
_1.dom.rangeList.forEach(range => { | ||
if (range._start[0] === cn) { | ||
@@ -516,3 +498,3 @@ range._start[0] = node; | ||
return interfaces_1.Position.Disconnected | interfaces_1.Position.ImplementationSpecific | | ||
(__1.dom.compareCache.check(this, other) ? interfaces_1.Position.Preceding : interfaces_1.Position.Following); | ||
(_1.dom.compareCache.check(this, other) ? interfaces_1.Position.Preceding : interfaces_1.Position.Following); | ||
} | ||
@@ -749,2 +731,20 @@ /** | ||
exports.NodeImpl = NodeImpl; | ||
NodeImpl.ELEMENT_NODE = 1; | ||
NodeImpl.ATTRIBUTE_NODE = 2; | ||
NodeImpl.TEXT_NODE = 3; | ||
NodeImpl.CDATA_SECTION_NODE = 4; | ||
NodeImpl.ENTITY_REFERENCE_NODE = 5; | ||
NodeImpl.ENTITY_NODE = 6; | ||
NodeImpl.PROCESSING_INSTRUCTION_NODE = 7; | ||
NodeImpl.COMMENT_NODE = 8; | ||
NodeImpl.DOCUMENT_NODE = 9; | ||
NodeImpl.DOCUMENT_TYPE_NODE = 10; | ||
NodeImpl.DOCUMENT_FRAGMENT_NODE = 11; | ||
NodeImpl.NOTATION_NODE = 12; | ||
NodeImpl.DOCUMENT_POSITION_DISCONNECTED = 0x01; | ||
NodeImpl.DOCUMENT_POSITION_PRECEDING = 0x02; | ||
NodeImpl.DOCUMENT_POSITION_FOLLOWING = 0x04; | ||
NodeImpl.DOCUMENT_POSITION_CONTAINS = 0x08; | ||
NodeImpl.DOCUMENT_POSITION_CONTAINED_BY = 0x10; | ||
NodeImpl.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20; | ||
//# sourceMappingURL=NodeImpl.js.map |
@@ -47,3 +47,3 @@ "use strict"; | ||
*/ | ||
algorithm_1.nodeIterator_iteratorList().remove(this); | ||
algorithm_1.nodeIterator_iteratorList().delete(this); | ||
} | ||
@@ -50,0 +50,0 @@ /** |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const __1 = require("../"); | ||
const _1 = require("./"); | ||
/** | ||
@@ -118,3 +118,3 @@ * Represents an ordered list of nodes. | ||
if (thisArg === undefined) { | ||
thisArg = __1.dom.window; | ||
thisArg = _1.dom.window; | ||
} | ||
@@ -121,0 +121,0 @@ let index = 0; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const __1 = require("../"); | ||
const _1 = require("./"); | ||
/** | ||
@@ -104,3 +104,3 @@ * Represents an ordered list of nodes. | ||
if (thisArg === undefined) { | ||
thisArg = __1.dom.window; | ||
thisArg = _1.dom.window; | ||
} | ||
@@ -107,0 +107,0 @@ let index = 0; |
@@ -9,6 +9,6 @@ import { Node, Range, HowToCompare, DocumentFragment, BoundaryPoint } from "./interfaces"; | ||
_end: BoundaryPoint; | ||
readonly START_TO_START: number; | ||
readonly START_TO_END: number; | ||
readonly END_TO_END: number; | ||
readonly END_TO_START: number; | ||
static START_TO_START: number; | ||
static START_TO_END: number; | ||
static END_TO_END: number; | ||
static END_TO_START: number; | ||
/** | ||
@@ -15,0 +15,0 @@ * Initializes a new instance of `Range`. |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const __1 = require("../"); | ||
const _1 = require("./"); | ||
const interfaces_1 = require("./interfaces"); | ||
@@ -18,6 +18,2 @@ const AbstractRangeImpl_1 = require("./AbstractRangeImpl"); | ||
super(); | ||
this.START_TO_START = 0; | ||
this.START_TO_END = 1; | ||
this.END_TO_END = 2; | ||
this.END_TO_START = 3; | ||
/** | ||
@@ -27,6 +23,6 @@ * The Range() constructor, when invoked, must return a new live range with | ||
*/ | ||
const doc = __1.dom.window._associatedDocument; | ||
const doc = _1.dom.window._associatedDocument; | ||
this._start = [doc, 0]; | ||
this._end = [doc, 0]; | ||
__1.dom.rangeList.add(this); | ||
_1.dom.rangeList.add(this); | ||
} | ||
@@ -414,3 +410,3 @@ /** @inheritdoc */ | ||
*/ | ||
__1.dom.rangeList.remove(this); | ||
_1.dom.rangeList.delete(this); | ||
} | ||
@@ -570,2 +566,6 @@ /** @inheritdoc */ | ||
exports.RangeImpl = RangeImpl; | ||
RangeImpl.START_TO_START = 0; | ||
RangeImpl.START_TO_END = 1; | ||
RangeImpl.END_TO_END = 2; | ||
RangeImpl.END_TO_START = 3; | ||
//# sourceMappingURL=RangeImpl.js.map |
import { Event, Slot, MutationObserver, Document, Window, NodeIterator } from "./interfaces"; | ||
import { EventTargetImpl } from "./EventTargetImpl"; | ||
import { ObjectCache } from "@oozcitak/util"; | ||
import { FixedSizeSet } from "@oozcitak/util"; | ||
/** | ||
@@ -13,3 +13,3 @@ * Represents a window containing a DOM document. | ||
_associatedDocument: Document; | ||
_iteratorList: ObjectCache<NodeIterator>; | ||
_iteratorList: FixedSizeSet<NodeIterator>; | ||
/** | ||
@@ -16,0 +16,0 @@ * Initializes a new instance of `Window`. |
@@ -18,3 +18,3 @@ "use strict"; | ||
this._mutationObservers = new Set(); | ||
this._iteratorList = new util_1.ObjectCache(); | ||
this._iteratorList = new util_1.FixedSizeSet(); | ||
this._associatedDocument = algorithm_1.create_document(); | ||
@@ -21,0 +21,0 @@ } |
@@ -1,6 +0,3 @@ | ||
import { DOM } from "./dom"; | ||
declare const domInstance: DOM; | ||
export { domInstance as dom }; | ||
export { DOMImplementation } from "./dom"; | ||
export { DOMParser } from "./parser"; | ||
export { XMLSerializer } from "./serializer"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const dom_1 = require("./dom"); | ||
const domInstance = dom_1.DOM.instance; | ||
exports.dom = domInstance; | ||
dom_1.dom.setFeatures(true); | ||
var dom_2 = require("./dom"); | ||
@@ -7,0 +6,0 @@ exports.DOMImplementation = dom_2.DOMImplementation; |
@@ -26,4 +26,3 @@ "use strict"; | ||
else { | ||
const lexer = new XMLStringLexer_1.XMLStringLexer(source); | ||
lexer.skipWhitespaceOnlyText = true; | ||
const lexer = new XMLStringLexer_1.XMLStringLexer(source, { skipWhitespaceOnlyText: true }); | ||
const doc = algorithm_1.create_document(); | ||
@@ -30,0 +29,0 @@ doc._contentType = mimeType; |
@@ -6,3 +6,3 @@ /** | ||
/** | ||
* Returns the token type. | ||
* Token type. | ||
*/ | ||
@@ -12,2 +12,75 @@ readonly type: TokenType; | ||
/** | ||
* Represents an end-of-file token. | ||
*/ | ||
export interface EOFToken extends XMLToken { | ||
readonly type: TokenType.EOF; | ||
} | ||
/** | ||
* Represents an XML declaration token. | ||
*/ | ||
export interface DeclarationToken extends XMLToken { | ||
readonly type: TokenType.Declaration; | ||
readonly version: string; | ||
readonly encoding: string; | ||
readonly standalone: string; | ||
} | ||
/** | ||
* Represents a DocType token. | ||
*/ | ||
export interface DocTypeToken extends XMLToken { | ||
readonly type: TokenType.DocType; | ||
readonly name: string; | ||
readonly pubId: string; | ||
readonly sysId: string; | ||
} | ||
/** | ||
* Represents a character data token. | ||
*/ | ||
export interface CharacterDataToken extends XMLToken { | ||
readonly data: string; | ||
} | ||
/** | ||
* Represents a comment token. | ||
*/ | ||
export interface CommentToken extends CharacterDataToken { | ||
readonly type: TokenType.Comment; | ||
} | ||
/** | ||
* Represents a CDATA token. | ||
*/ | ||
export interface CDATAToken extends CharacterDataToken { | ||
readonly type: TokenType.CDATA; | ||
} | ||
/** | ||
* Represents a text token. | ||
*/ | ||
export interface TextToken extends CharacterDataToken { | ||
readonly type: TokenType.Text; | ||
} | ||
/** | ||
* Represents a processing instruction token. | ||
*/ | ||
export interface PIToken extends CharacterDataToken { | ||
readonly type: TokenType.PI; | ||
readonly target: string; | ||
} | ||
/** | ||
* Represents an element token. | ||
*/ | ||
export interface ElementToken extends XMLToken { | ||
readonly type: TokenType.Element; | ||
readonly name: string; | ||
readonly attributes: { | ||
[key: string]: string; | ||
}; | ||
readonly selfClosing: boolean; | ||
} | ||
/** | ||
* Represents a closing tag token. | ||
*/ | ||
export interface ClosingTagToken extends XMLToken { | ||
readonly type: TokenType.ClosingTag; | ||
readonly name: string; | ||
} | ||
/** | ||
* Represents a lexer for XML content. | ||
@@ -22,2 +95,11 @@ */ | ||
/** | ||
* Defines lexer options. | ||
*/ | ||
export declare type XMLLexerOptions = { | ||
/** | ||
* Determines whether whitespace-only text nodes are skipped or not. | ||
*/ | ||
skipWhitespaceOnlyText: boolean; | ||
}; | ||
/** | ||
* Defines the type of a token. | ||
@@ -24,0 +106,0 @@ */ |
@@ -1,2 +0,2 @@ | ||
import { XMLToken, XMLLexer } from "./interfaces"; | ||
import { XMLToken, XMLLexer, XMLLexerOptions } from "./interfaces"; | ||
/** | ||
@@ -6,3 +6,7 @@ * Represents a lexer for XML content in a string. | ||
export declare class XMLStringLexer implements XMLLexer { | ||
private _walker; | ||
private static _WhiteSpace; | ||
private _str; | ||
private _index; | ||
private _length; | ||
private _options; | ||
/** | ||
@@ -12,9 +16,6 @@ * Initializes a new instance of `XMLStringLexer`. | ||
* @param str - the string to tokenize and lex | ||
* @param options - lexer options | ||
*/ | ||
constructor(str: string); | ||
constructor(str: string, options?: Partial<XMLLexerOptions>); | ||
/** | ||
* Determines whether whitespace-only text nodes are skipped or not. | ||
*/ | ||
skipWhitespaceOnlyText: boolean; | ||
/** | ||
* Returns the next token. | ||
@@ -64,2 +65,69 @@ */ | ||
/** | ||
* Determines if the current index is at or past the end of input string. | ||
*/ | ||
private eof; | ||
/** | ||
* Returns the current character. | ||
*/ | ||
private c; | ||
/** | ||
* Skips the length of the given string if the string from current position | ||
* starts with the given string. | ||
* | ||
* @param str - the string to match | ||
*/ | ||
private skipIfStartsWith; | ||
/** | ||
* Seeks a number of character codes. | ||
* | ||
* @param count - number of characters to skip | ||
*/ | ||
private seek; | ||
/** | ||
* Skips space characters. | ||
*/ | ||
private skipSpace; | ||
/** | ||
* Takes characters until the next character matches `char`. | ||
* | ||
* @param char - a character to match | ||
* @param space - whether a space character stops iteration | ||
*/ | ||
private takeUntil; | ||
/** | ||
* Takes characters until the next character matches `char1` or `char1`. | ||
* | ||
* @param char1 - a character to match | ||
* @param char2 - a character to match | ||
* @param space - whether a space character stops iteration | ||
*/ | ||
private takeUntil2; | ||
/** | ||
* Takes characters until the next characters matches `str`. | ||
* | ||
* @param str - a string to match | ||
* @param space - whether a space character stops iteration | ||
*/ | ||
private takeUntilStartsWith; | ||
/** | ||
* Skips characters while the next character matches `char`. | ||
* | ||
* @param char - a character to match | ||
* @param space - whether to skip space characters as well | ||
*/ | ||
private skipWhile; | ||
/** | ||
* Skips characters until the next character matches `char`. | ||
* | ||
* @param char - a character to match | ||
* @param space - whether to skip space characters as well | ||
*/ | ||
private skipUntil; | ||
/** | ||
* Determines if the given token is entirely whitespace. | ||
* | ||
* @param token - the token to check | ||
*/ | ||
private static isWhiteSpaceToken; | ||
/** | ||
* Determines if the given character is whitespace. | ||
@@ -66,0 +134,0 @@ * |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const XMLToken_1 = require("./XMLToken"); | ||
const interfaces_1 = require("./interfaces"); | ||
const util_1 = require("@oozcitak/util"); | ||
/** | ||
@@ -14,9 +12,14 @@ * Represents a lexer for XML content in a string. | ||
* @param str - the string to tokenize and lex | ||
* @param options - lexer options | ||
*/ | ||
constructor(str) { | ||
/** | ||
* Determines whether whitespace-only text nodes are skipped or not. | ||
*/ | ||
this.skipWhitespaceOnlyText = false; | ||
this._walker = new util_1.StringWalker(str); | ||
constructor(str, options) { | ||
this._options = { | ||
skipWhitespaceOnlyText: false | ||
}; | ||
this._str = str; | ||
this._index = 0; | ||
this._length = str.length; | ||
if (options) { | ||
this._options.skipWhitespaceOnlyText = options.skipWhitespaceOnlyText || false; | ||
} | ||
} | ||
@@ -27,9 +30,7 @@ /** | ||
nextToken() { | ||
if (this._walker.eof) { | ||
return new XMLToken_1.EOFToken(); | ||
if (this.eof()) { | ||
return { type: interfaces_1.TokenType.EOF }; | ||
} | ||
let token = new XMLToken_1.EOFToken(); | ||
const char = this._walker.c; | ||
if (char === '<') { | ||
this._walker.next(); | ||
let token = { type: interfaces_1.TokenType.EOF }; | ||
if (this.skipIfStartsWith('<')) { | ||
token = this.openBracket(); | ||
@@ -40,8 +41,5 @@ } | ||
} | ||
if (this.skipWhitespaceOnlyText) { | ||
if (token.type === interfaces_1.TokenType.Text) { | ||
const textToken = token; | ||
if (textToken.isWhitespace) { | ||
token = this.nextToken(); | ||
} | ||
if (this._options.skipWhitespaceOnlyText) { | ||
if (token.type === interfaces_1.TokenType.Text && XMLStringLexer.isWhiteSpaceToken(token)) { | ||
token = this.nextToken(); | ||
} | ||
@@ -55,7 +53,6 @@ } | ||
openBracket() { | ||
switch (this._walker.c) { | ||
switch (this.c()) { | ||
case '?': | ||
this._walker.next(); | ||
if (this._walker.startsWith('xml')) { | ||
this._walker.seek(3); | ||
this.seek(1); | ||
if (this.skipIfStartsWith('xml')) { | ||
return this.declaration(); | ||
@@ -67,17 +64,17 @@ } | ||
case '!': | ||
this._walker.next(); | ||
if (this._walker.startsWith('--')) { | ||
this._walker.seek(2); | ||
this.seek(1); | ||
if (this.skipIfStartsWith('--')) { | ||
return this.comment(); | ||
} | ||
else if (this._walker.startsWith('[CDATA[')) { | ||
this._walker.seek(7); | ||
else if (this.skipIfStartsWith('[CDATA[')) { | ||
return this.cdata(); | ||
} | ||
else if (this._walker.startsWith('DOCTYPE')) { | ||
this._walker.seek(7); | ||
else if (this.skipIfStartsWith('DOCTYPE')) { | ||
return this.doctype(); | ||
} | ||
else { | ||
throw new Error("Invalid '!' in opening tag."); | ||
} | ||
case '/': | ||
this._walker.next(); | ||
this.seek(1); | ||
return this.closeTag(); | ||
@@ -92,42 +89,27 @@ default: | ||
declaration() { | ||
let attName = ''; | ||
let attValue = ''; | ||
let version = ''; | ||
let encoding = ''; | ||
let standalone = ''; | ||
let inName = false; | ||
let inValue = false; | ||
let startQuote = ''; | ||
this._walker.skip(c => XMLStringLexer.isSpace(c)); | ||
inName = true; | ||
inValue = false; | ||
while (!this._walker.eof) { | ||
let char = this._walker.take(1); | ||
const nextChar = this._walker.c; | ||
if (char === '?' && nextChar === '>') { | ||
this._walker.seek(1); | ||
return new XMLToken_1.DeclarationToken(version, encoding, standalone); | ||
while (!this.eof()) { | ||
this.skipSpace(); | ||
if (this.skipIfStartsWith('?>')) { | ||
return { type: interfaces_1.TokenType.Declaration, version: version, encoding: encoding, standalone: standalone }; | ||
} | ||
else if (inName && XMLStringLexer.isSpace(char) || char === '=') { | ||
inName = false; | ||
inValue = true; | ||
this._walker.skip(c => XMLStringLexer.isSpace(c)); | ||
while (!this._walker.eof && char !== '=') { | ||
char = this._walker.take(1); | ||
} | ||
if (char !== '=') { | ||
else { | ||
const attName = this.takeUntil('=', true); | ||
this.skipSpace(); | ||
if (this.c() !== '=') { | ||
throw new Error('Missing equals sign before attribute value'); | ||
} | ||
this._walker.skip(c => XMLStringLexer.isSpace(c)); | ||
startQuote = this._walker.take(1); | ||
this.skipWhile('=', true); | ||
const startQuote = this.c(); | ||
if (!XMLStringLexer.isQuote(startQuote)) { | ||
throw new Error('Missing quote character before attribute value'); | ||
throw new Error('Missing start quote character before attribute value'); | ||
} | ||
} | ||
else if (inName) { | ||
attName += char; | ||
} | ||
else if (inValue && char === startQuote) { | ||
inName = true; | ||
inValue = false; | ||
this.seek(1); | ||
const attValue = this.takeUntil(startQuote); | ||
if (this.c() !== startQuote) { | ||
throw new Error('Missing end quote character after attribute value'); | ||
} | ||
this.seek(1); | ||
if (attName === 'version') | ||
@@ -141,9 +123,3 @@ version = attValue; | ||
throw new Error('Invalid attribute name: ' + attName); | ||
attName = ''; | ||
attValue = ''; | ||
this._walker.skip(c => XMLStringLexer.isSpace(c)); | ||
} | ||
else if (inValue) { | ||
attValue += char; | ||
} | ||
} | ||
@@ -156,106 +132,63 @@ throw new Error('Missing declaration end symbol `?>`'); | ||
doctype() { | ||
let name = ''; | ||
let pubId = ''; | ||
let sysId = ''; | ||
// name | ||
this._walker.skip(c => XMLStringLexer.isSpace(c)); | ||
while (!this._walker.eof) { | ||
const char = this._walker.c; | ||
if (char === '>') { | ||
this._walker.next(); | ||
return new XMLToken_1.DocTypeToken(name, '', ''); | ||
} | ||
else if (char === '[') { | ||
break; | ||
} | ||
else if (XMLStringLexer.isSpace(char)) { | ||
this._walker.next(); | ||
break; | ||
} | ||
else { | ||
this._walker.next(); | ||
name += char; | ||
} | ||
} | ||
this._walker.skip(c => XMLStringLexer.isSpace(c)); | ||
if (this._walker.startsWith('PUBLIC')) { | ||
this._walker.seek(6); | ||
this.skipSpace(); | ||
const name = this.takeUntil2('[', '>', true); | ||
this.skipSpace(); | ||
if (this.skipIfStartsWith('PUBLIC')) { | ||
// pubId | ||
this._walker.skip(c => XMLStringLexer.isSpace(c)); | ||
let startQuote = this._walker.take(1); | ||
this.skipSpace(); | ||
let startQuote = this.c(); | ||
if (!XMLStringLexer.isQuote(startQuote)) { | ||
throw new Error('Missing quote character before pubId value'); | ||
throw new Error('Missing start quote character before pubId value'); | ||
} | ||
while (!this._walker.eof) { | ||
const char = this._walker.take(1); | ||
if (char === startQuote) { | ||
break; | ||
} | ||
else { | ||
pubId += char; | ||
} | ||
this.seek(1); | ||
pubId = this.takeUntil(startQuote); | ||
if (this.c() !== startQuote) { | ||
throw new Error('Missing end quote character after pubId value'); | ||
} | ||
this.seek(1); | ||
// sysId | ||
this._walker.skip(c => XMLStringLexer.isSpace(c)); | ||
startQuote = this._walker.take(1); | ||
this.skipSpace(); | ||
startQuote = this.c(); | ||
if (!XMLStringLexer.isQuote(startQuote)) { | ||
throw new Error('Missing quote character before sysId value'); | ||
throw new Error('Missing start quote character before sysId value'); | ||
} | ||
while (!this._walker.eof) { | ||
const char = this._walker.take(1); | ||
if (char === startQuote) { | ||
break; | ||
} | ||
else { | ||
sysId += char; | ||
} | ||
this.seek(1); | ||
sysId = this.takeUntil(startQuote); | ||
if (this.c() !== startQuote) { | ||
throw new Error('Missing end quote character after sysId value'); | ||
} | ||
this.seek(1); | ||
} | ||
else if (this._walker.startsWith('SYSTEM')) { | ||
this._walker.seek(6); | ||
else if (this.skipIfStartsWith('SYSTEM')) { | ||
// sysId | ||
this._walker.skip(c => XMLStringLexer.isSpace(c)); | ||
let startQuote = this._walker.take(1); | ||
this.skipSpace(); | ||
const startQuote = this.c(); | ||
if (!XMLStringLexer.isQuote(startQuote)) { | ||
throw new Error('Missing quote character before sysId value'); | ||
throw new Error('Missing start quote character before sysId value'); | ||
} | ||
while (!this._walker.eof) { | ||
const char = this._walker.take(1); | ||
if (char === startQuote) { | ||
break; | ||
} | ||
else { | ||
sysId += char; | ||
} | ||
this.seek(1); | ||
sysId = this.takeUntil(startQuote); | ||
if (this.c() !== startQuote) { | ||
throw new Error('Missing end quote character after sysId value'); | ||
} | ||
this.seek(1); | ||
} | ||
// skip internal subset | ||
let hasInternalSubset = false; | ||
this._walker.skip(c => XMLStringLexer.isSpace(c)); | ||
while (!this._walker.eof) { | ||
const char = this._walker.take(1); | ||
if (char === '>') { | ||
return new XMLToken_1.DocTypeToken(name, pubId, sysId); | ||
this.skipSpace(); | ||
if (this.c() === '[') { | ||
this.skipUntil(']'); | ||
if (this.c() !== ']') { | ||
throw new Error('Missing end bracket of DTD internal subset'); | ||
} | ||
else if (char === '[') { | ||
hasInternalSubset = true; | ||
break; | ||
} | ||
this.seek(1); | ||
} | ||
if (hasInternalSubset) { | ||
while (!this._walker.eof) { | ||
const char = this._walker.take(1); | ||
if (char === ']') { | ||
break; | ||
} | ||
} | ||
this._walker.skip(c => XMLStringLexer.isSpace(c)); | ||
while (!this._walker.eof) { | ||
const char = this._walker.take(1); | ||
if (char === '>') { | ||
return new XMLToken_1.DocTypeToken(name, pubId, sysId); | ||
} | ||
} | ||
this.skipSpace(); | ||
if (this.c() !== '>') { | ||
throw new Error('Missing doctype end symbol `>`'); | ||
} | ||
throw new Error('Missing doctype end symbol `>`'); | ||
this.seek(1); | ||
return { type: interfaces_1.TokenType.DocType, name: name, pubId: pubId, sysId: sysId }; | ||
} | ||
@@ -266,31 +199,13 @@ /** | ||
pi() { | ||
let target = ''; | ||
while (!this._walker.eof) { | ||
const char = this._walker.take(1); | ||
const nextChar = this._walker.c; | ||
const endTag = (char === '?' && nextChar === '>'); | ||
if (XMLStringLexer.isSpace(char) || endTag) { | ||
if (endTag) { | ||
this._walker.seek(1); | ||
return new XMLToken_1.PIToken(target, ''); | ||
} | ||
break; | ||
} | ||
else { | ||
target += char; | ||
} | ||
const target = this.takeUntilStartsWith('?>', true); | ||
this.skipSpace(); | ||
if (this.skipIfStartsWith('?>')) { | ||
return { type: interfaces_1.TokenType.PI, target: target, data: '' }; | ||
} | ||
let data = ''; | ||
while (!this._walker.eof) { | ||
const char = this._walker.take(1); | ||
const nextChar = this._walker.c; | ||
if (char === '?' && nextChar === '>') { | ||
this._walker.seek(1); | ||
return new XMLToken_1.PIToken(target, data); | ||
} | ||
else { | ||
data += char; | ||
} | ||
const data = this.takeUntilStartsWith('?>'); | ||
if (this.eof()) { | ||
throw new Error('Missing processing instruction end symbol `?>`'); | ||
} | ||
throw new Error('Missing processing instruction end symbol `?>`'); | ||
this.seek(2); | ||
return { type: interfaces_1.TokenType.PI, target: target, data: data }; | ||
} | ||
@@ -302,12 +217,4 @@ /** | ||
text() { | ||
let data = ''; | ||
while (!this._walker.eof) { | ||
const char = this._walker.c; | ||
if (char === '<') { | ||
break; | ||
} | ||
data += char; | ||
this._walker.next(); | ||
} | ||
return new XMLToken_1.TextToken(data); | ||
const data = this.takeUntil('<'); | ||
return { type: interfaces_1.TokenType.Text, data: data }; | ||
} | ||
@@ -319,12 +226,8 @@ /** | ||
comment() { | ||
let data = ''; | ||
while (!this._walker.eof) { | ||
const char = this._walker.take(1); | ||
if (char === '-' && this._walker.startsWith('->')) { | ||
this._walker.seek(2); | ||
return new XMLToken_1.CommentToken(data); | ||
} | ||
data += char; | ||
const data = this.takeUntilStartsWith('-->'); | ||
if (this.eof()) { | ||
throw new Error('Missing comment end symbol `-->`'); | ||
} | ||
throw new Error('Missing comment end symbol `-->`'); | ||
this.seek(3); | ||
return { type: interfaces_1.TokenType.Comment, data: data }; | ||
} | ||
@@ -336,12 +239,8 @@ /** | ||
cdata() { | ||
let data = ''; | ||
while (!this._walker.eof) { | ||
const char = this._walker.take(1); | ||
if (char === ']' && this._walker.startsWith(']>')) { | ||
this._walker.seek(2); | ||
return new XMLToken_1.CDATAToken(data); | ||
} | ||
data += char; | ||
const data = this.takeUntilStartsWith(']]>'); | ||
if (this.eof()) { | ||
throw new Error('Missing CDATA end symbol `]>`'); | ||
} | ||
throw new Error('Missing CDATA end symbol `]>`'); | ||
this.seek(3); | ||
return { type: interfaces_1.TokenType.CDATA, data: data }; | ||
} | ||
@@ -352,94 +251,219 @@ /** | ||
openTag() { | ||
let name = ''; | ||
let attributes = {}; | ||
let attName = ''; | ||
let attValue = ''; | ||
let inAttName = false; | ||
let inAttValue = false; | ||
let startQuote = ''; | ||
// element name | ||
this._walker.skip(c => XMLStringLexer.isSpace(c)); | ||
while (!this._walker.eof) { | ||
const char = this._walker.take(1); | ||
const nextChar = this._walker.c; | ||
if (char === '>') { | ||
return new XMLToken_1.ElementToken(name, {}, false); | ||
this.skipSpace(); | ||
const name = this.takeUntil2('>', '/', true); | ||
if (this.c() === '>') { | ||
this.seek(1); | ||
return { type: interfaces_1.TokenType.Element, name: name, attributes: {}, selfClosing: false }; | ||
} | ||
else if (this.skipIfStartsWith('/>')) { | ||
return { type: interfaces_1.TokenType.Element, name: name, attributes: {}, selfClosing: true }; | ||
} | ||
// attributes | ||
const attributes = {}; | ||
while (!this.eof()) { | ||
// end tag | ||
this.skipSpace(); | ||
if (this.c() === '>') { | ||
this.seek(1); | ||
return { type: interfaces_1.TokenType.Element, name: name, attributes: attributes, selfClosing: false }; | ||
} | ||
else if (char === '/' && nextChar === '>') { | ||
this._walker.seek(1); | ||
return new XMLToken_1.ElementToken(name, {}, true); | ||
else if (this.skipIfStartsWith('/>')) { | ||
return { type: interfaces_1.TokenType.Element, name: name, attributes: attributes, selfClosing: true }; | ||
} | ||
else if (XMLStringLexer.isSpace(char)) { | ||
// attribute name | ||
const attName = this.takeUntil('=', true); | ||
this.skipSpace(); | ||
if (this.c() !== '=') { | ||
throw new Error('Missing equals sign before attribute value'); | ||
} | ||
this.seek(1); | ||
// attribute value | ||
this.skipSpace(); | ||
const startQuote = this.c(); | ||
if (!XMLStringLexer.isQuote(startQuote)) { | ||
throw new Error('Missing start quote character before attribute value'); | ||
} | ||
this.seek(1); | ||
const attValue = this.takeUntil(startQuote); | ||
if (this.c() !== startQuote) { | ||
throw new Error('Missing end quote character after attribute value'); | ||
} | ||
this.seek(1); | ||
attributes[attName] = attValue; | ||
} | ||
throw new Error('Missing opening element tag end symbol `>`'); | ||
} | ||
/** | ||
* Produces a closing tag token. | ||
* | ||
*/ | ||
closeTag() { | ||
this.skipSpace(); | ||
const name = this.takeUntil('>', true); | ||
this.skipSpace(); | ||
if (this.c() !== '>') { | ||
throw new Error('Missing closing element tag end symbol `>`'); | ||
} | ||
this.seek(1); | ||
return { type: interfaces_1.TokenType.ClosingTag, name: name }; | ||
} | ||
/** | ||
* Determines if the current index is at or past the end of input string. | ||
*/ | ||
eof() { return this._index >= this._length; } | ||
/** | ||
* Returns the current character. | ||
*/ | ||
c() { return this._str[this._index]; } | ||
/** | ||
* Skips the length of the given string if the string from current position | ||
* starts with the given string. | ||
* | ||
* @param str - the string to match | ||
*/ | ||
skipIfStartsWith(str) { | ||
const strLength = str.length; | ||
if (this._index + strLength > this._length) | ||
return false; | ||
for (let i = 0; i < strLength; i++) { | ||
if (this._str[this._index + i] !== str[i]) | ||
return false; | ||
} | ||
this._index += strLength; | ||
return true; | ||
} | ||
/** | ||
* Seeks a number of character codes. | ||
* | ||
* @param count - number of characters to skip | ||
*/ | ||
seek(count) { | ||
this._index += count; | ||
if (this._index < 0) | ||
this._index = 0; | ||
if (this._index > this._length) | ||
this._index = this._length; | ||
} | ||
/** | ||
* Skips space characters. | ||
*/ | ||
skipSpace() { | ||
while (!this.eof()) { | ||
if (!XMLStringLexer.isSpace(this._str[this._index])) | ||
break; | ||
this._index++; | ||
} | ||
} | ||
/** | ||
* Takes characters until the next character matches `char`. | ||
* | ||
* @param char - a character to match | ||
* @param space - whether a space character stops iteration | ||
*/ | ||
takeUntil(char, space = false) { | ||
const startIndex = this._index; | ||
while (this._index < this._length) { | ||
const c = this._str[this._index]; | ||
if (c !== char && (!space || !XMLStringLexer.isSpace(c))) { | ||
this._index++; | ||
} | ||
else { | ||
name += char; | ||
break; | ||
} | ||
} | ||
// attributes | ||
this._walker.skip(c => XMLStringLexer.isSpace(c)); | ||
inAttName = true; | ||
inAttValue = false; | ||
while (!this._walker.eof) { | ||
let char = this._walker.take(1); | ||
const nextChar = this._walker.c; | ||
if (char === '>') { | ||
return new XMLToken_1.ElementToken(name, attributes, false); | ||
return this._str.slice(startIndex, this._index); | ||
} | ||
/** | ||
* Takes characters until the next character matches `char1` or `char1`. | ||
* | ||
* @param char1 - a character to match | ||
* @param char2 - a character to match | ||
* @param space - whether a space character stops iteration | ||
*/ | ||
takeUntil2(char1, char2, space = false) { | ||
const startIndex = this._index; | ||
while (this._index < this._length) { | ||
const c = this._str[this._index]; | ||
if (c !== char1 && c !== char2 && (!space || !XMLStringLexer.isSpace(c))) { | ||
this._index++; | ||
} | ||
else if (char === '/' && nextChar === '>') { | ||
this._walker.seek(1); | ||
return new XMLToken_1.ElementToken(name, attributes, true); | ||
else { | ||
break; | ||
} | ||
else if (inAttName && XMLStringLexer.isSpace(char) || char === '=') { | ||
inAttName = false; | ||
inAttValue = true; | ||
this._walker.skip(c => XMLStringLexer.isSpace(c)); | ||
while (!this._walker.eof && char !== '=') { | ||
char = this._walker.take(1); | ||
} | ||
return this._str.slice(startIndex, this._index); | ||
} | ||
/** | ||
* Takes characters until the next characters matches `str`. | ||
* | ||
* @param str - a string to match | ||
* @param space - whether a space character stops iteration | ||
*/ | ||
takeUntilStartsWith(str, space = false) { | ||
const startIndex = this._index; | ||
const strLength = str.length; | ||
while (this._index < this._length) { | ||
let match = true; | ||
for (let i = 0; i < strLength; i++) { | ||
const c = this._str[this._index + i]; | ||
const char = str[i]; | ||
if (space && XMLStringLexer.isSpace(c)) { | ||
return this._str.slice(startIndex, this._index); | ||
} | ||
if (char !== '=') { | ||
throw new Error('Missing equals sign before attribute value'); | ||
else if (c !== char) { | ||
this._index++; | ||
match = false; | ||
break; | ||
} | ||
this._walker.skip(c => XMLStringLexer.isSpace(c)); | ||
startQuote = this._walker.take(1); | ||
if (!XMLStringLexer.isQuote(startQuote)) { | ||
throw new Error('Missing quote character before attribute value'); | ||
} | ||
} | ||
else if (inAttName) { | ||
attName += char; | ||
if (match) | ||
return this._str.slice(startIndex, this._index); | ||
} | ||
this._index = this._length; | ||
return this._str.slice(startIndex); | ||
} | ||
/** | ||
* Skips characters while the next character matches `char`. | ||
* | ||
* @param char - a character to match | ||
* @param space - whether to skip space characters as well | ||
*/ | ||
skipWhile(char, space = false) { | ||
while (this._index < this._length) { | ||
const c = this._str[this._index]; | ||
if (c === char || (space && XMLStringLexer.isSpace(c))) { | ||
this._index++; | ||
} | ||
else if (inAttValue && char === startQuote) { | ||
inAttName = true; | ||
inAttValue = false; | ||
attributes[attName] = attValue; | ||
attName = ''; | ||
attValue = ''; | ||
this._walker.skip(c => XMLStringLexer.isSpace(c)); | ||
else { | ||
break; | ||
} | ||
else if (inAttValue) { | ||
attValue += char; | ||
} | ||
} | ||
throw new Error('Missing opening element tag end symbol `>`'); | ||
} | ||
/** | ||
* Produces a closing tag token. | ||
* Skips characters until the next character matches `char`. | ||
* | ||
* @param char - a character to match | ||
* @param space - whether to skip space characters as well | ||
*/ | ||
closeTag() { | ||
let name = ''; | ||
this._walker.skip(c => XMLStringLexer.isSpace(c)); | ||
while (!this._walker.eof) { | ||
const char = this._walker.take(1); | ||
if (char === '>') { | ||
return new XMLToken_1.ClosingTagToken(name); | ||
skipUntil(char, space = false) { | ||
while (this._index < this._length) { | ||
const c = this._str[this._index]; | ||
if (c !== char && (!space || !XMLStringLexer.isSpace(c))) { | ||
this._index++; | ||
} | ||
else if (!XMLStringLexer.isSpace(char)) { | ||
name += char; | ||
else { | ||
break; | ||
} | ||
} | ||
throw new Error('Missing closing element tag end symbol `>`'); | ||
} | ||
/** | ||
* Determines if the given token is entirely whitespace. | ||
* | ||
* @param token - the token to check | ||
*/ | ||
static isWhiteSpaceToken(token) { | ||
return XMLStringLexer._WhiteSpace.test(token.data); | ||
} | ||
/** | ||
* Determines if the given character is whitespace. | ||
@@ -464,3 +488,3 @@ * | ||
[Symbol.iterator]() { | ||
this._walker.seek(0, util_1.SeekOrigin.Start); | ||
this._index = 0; | ||
return { | ||
@@ -480,2 +504,3 @@ next: function () { | ||
exports.XMLStringLexer = XMLStringLexer; | ||
XMLStringLexer._WhiteSpace = /^[ \n\r\t\f]*$/; | ||
//# sourceMappingURL=XMLStringLexer.js.map |
@@ -5,3 +5,3 @@ /** | ||
*/ | ||
export declare class TupleSet<T1, T2> implements Iterable<[T1, T2]> { | ||
export declare class TupleSet<T1, T2> { | ||
private _storage; | ||
@@ -33,6 +33,2 @@ /** | ||
/** | ||
* Returns an iterator for the set. | ||
*/ | ||
entries(): IterableIterator<[T1, T2]>; | ||
/** | ||
* Calls the callback function for each tuple in the set. The callback | ||
@@ -53,10 +49,2 @@ * receives arguments as follows: | ||
has(val: [T1, T2]): boolean; | ||
/** | ||
* Returns an iterator for the set. | ||
*/ | ||
values(): IterableIterator<[T1, T2]>; | ||
/** | ||
* Returns an iterator for the set. | ||
*/ | ||
[Symbol.iterator](): IterableIterator<[T1, T2]>; | ||
} |
@@ -56,8 +56,2 @@ "use strict"; | ||
/** | ||
* Returns an iterator for the set. | ||
*/ | ||
*entries() { | ||
yield* this; | ||
} | ||
/** | ||
* Calls the callback function for each tuple in the set. The callback | ||
@@ -83,20 +77,4 @@ * receives arguments as follows: | ||
} | ||
/** | ||
* Returns an iterator for the set. | ||
*/ | ||
*values() { | ||
yield* this; | ||
} | ||
/** | ||
* Returns an iterator for the set. | ||
*/ | ||
*[Symbol.iterator]() { | ||
for (const [key, subSet] of this._storage.entries()) { | ||
for (const val of subSet) { | ||
yield [key, val]; | ||
} | ||
} | ||
} | ||
} | ||
exports.TupleSet = TupleSet; | ||
//# sourceMappingURL=TupleSet.js.map |
{ | ||
"name": "@oozcitak/dom", | ||
"version": "1.1.1", | ||
"version": "1.2.1", | ||
"keywords": [ | ||
@@ -28,3 +28,3 @@ "dom", | ||
"dependencies": { | ||
"@oozcitak/util": "2.1.0", | ||
"@oozcitak/util": "4.0.0", | ||
"@oozcitak/infra": "1.0.4", | ||
@@ -31,0 +31,0 @@ "@oozcitak/url": "1.0.0" |
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
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
1066437
264
21331
+ Added@oozcitak/util@4.0.0(transitive)
- Removed@oozcitak/util@2.1.0(transitive)
Updated@oozcitak/util@4.0.0