Comparing version 0.1.16 to 0.1.17
@@ -11,3 +11,6 @@ 'use strict'; | ||
const {findNext, getEnd, invalidate} = require('./utils.js'); | ||
const { | ||
findNext, | ||
getEnd | ||
} = require('./utils.js'); | ||
@@ -70,4 +73,3 @@ const asFragment = (ownerDocument, nodes) => { | ||
node.parentNode = node._prev = _end._next = null; | ||
if (parentNode) | ||
invalidate(parentNode); | ||
// if (parentNode) invalidate(parentNode); | ||
} | ||
@@ -142,3 +144,3 @@ }; | ||
const append = (element, nodes) => { | ||
invalidate(element); | ||
// invalidate(element); | ||
const {ownerDocument, _end} = element; | ||
@@ -207,3 +209,3 @@ for (const node of nodes) | ||
prepend(element, nodes) { | ||
invalidate(element); | ||
// invalidate(element); | ||
const {ownerDocument, firstChild} = element; | ||
@@ -224,3 +226,3 @@ for (const node of nodes) | ||
replaceChildren(element, nodes) { | ||
invalidate(element); | ||
// invalidate(element); | ||
let {_next, _end} = element; | ||
@@ -227,0 +229,0 @@ while (_next !== _end) { |
@@ -20,4 +20,3 @@ 'use strict'; | ||
getBoundaries, | ||
getEnd, | ||
invalidate | ||
getEnd | ||
} = require('./utils.js'); | ||
@@ -247,8 +246,14 @@ | ||
super(ownerDocument, localName, nodeType); | ||
invalidate(this); | ||
// invalidate(this); | ||
} | ||
get childNodes() { | ||
return getChildNodes(this); | ||
// return this._childNodes || (this._childNodes = getChildNodes(this)); | ||
} | ||
// <ParentNode> | ||
get children() { | ||
return this._children || (this._children = ParentNode.children(this)); | ||
return ParentNode.children(this); | ||
// return this._children || (this._children = ParentNode.children(this)); | ||
} | ||
@@ -322,6 +327,2 @@ | ||
get childNodes() { | ||
return this._childNodes || (this._childNodes = getChildNodes(this)); | ||
} | ||
/** | ||
@@ -348,3 +349,3 @@ * @param {Node} node | ||
appendChild(node) { | ||
invalidate(this); | ||
// invalidate(this); | ||
return this.insertBefore(node, this._end); | ||
@@ -359,3 +360,3 @@ } | ||
insertBefore(node, before) { | ||
invalidate(this); | ||
// invalidate(this); | ||
const _end = before || this._end; | ||
@@ -374,3 +375,3 @@ const {_prev} = _end; | ||
case DOCUMENT_FRAGMENT_NODE: { | ||
invalidate(node); | ||
// invalidate(node); | ||
let {firstChild, lastChild} = node; | ||
@@ -409,3 +410,3 @@ if (firstChild) { | ||
normalize() { | ||
let invalidated = false; | ||
let shouldInvalidate = false; | ||
let {_next, _end} = this; | ||
@@ -416,7 +417,7 @@ while (_next !== _end) { | ||
if (!_next.textContent) { | ||
invalidated = true; | ||
shouldInvalidate = true; | ||
_next.remove(); | ||
} | ||
else if (_prev && _prev.nodeType === TEXT_NODE) { | ||
invalidated = true; | ||
shouldInvalidate = true; | ||
_prev.textContent += _next.textContent; | ||
@@ -428,4 +429,3 @@ _next.remove(); | ||
} | ||
if (invalidated) | ||
invalidate(this); | ||
// if (shouldInvalidate) invalidate(this); | ||
} | ||
@@ -440,3 +440,2 @@ | ||
throw new Error('node is not a child'); | ||
invalidate(this); | ||
node.remove(); | ||
@@ -453,3 +452,3 @@ return node; | ||
const {_prev, _next} = getBoundaries(replaced); | ||
invalidate(this); | ||
// invalidate(this); | ||
replaced.remove(); | ||
@@ -456,0 +455,0 @@ node.remove(); |
@@ -62,6 +62,3 @@ 'use strict'; | ||
const invalidate = element => { | ||
element._childNodes = element._children = null; | ||
}; | ||
exports.invalidate = invalidate; | ||
// export const invalidate = $ => { $._childNodes = $._children = null; }; | ||
@@ -68,0 +65,0 @@ const isVoidElement = ({localName, ownerDocument}) => { |
@@ -10,3 +10,7 @@ import { | ||
import {findNext, getEnd, invalidate} from './utils.js'; | ||
import { | ||
findNext, | ||
getEnd, | ||
// invalidate | ||
} from './utils.js'; | ||
@@ -69,4 +73,3 @@ const asFragment = (ownerDocument, nodes) => { | ||
node.parentNode = node._prev = _end._next = null; | ||
if (parentNode) | ||
invalidate(parentNode); | ||
// if (parentNode) invalidate(parentNode); | ||
} | ||
@@ -138,3 +141,3 @@ }; | ||
const append = (element, nodes) => { | ||
invalidate(element); | ||
// invalidate(element); | ||
const {ownerDocument, _end} = element; | ||
@@ -203,3 +206,3 @@ for (const node of nodes) | ||
prepend(element, nodes) { | ||
invalidate(element); | ||
// invalidate(element); | ||
const {ownerDocument, firstChild} = element; | ||
@@ -220,3 +223,3 @@ for (const node of nodes) | ||
replaceChildren(element, nodes) { | ||
invalidate(element); | ||
// invalidate(element); | ||
let {_next, _end} = element; | ||
@@ -223,0 +226,0 @@ while (_next !== _end) { |
@@ -20,3 +20,3 @@ import { | ||
getEnd, | ||
invalidate | ||
// invalidate | ||
} from './utils.js'; | ||
@@ -245,8 +245,14 @@ | ||
super(ownerDocument, localName, nodeType); | ||
invalidate(this); | ||
// invalidate(this); | ||
} | ||
get childNodes() { | ||
return getChildNodes(this); | ||
// return this._childNodes || (this._childNodes = getChildNodes(this)); | ||
} | ||
// <ParentNode> | ||
get children() { | ||
return this._children || (this._children = ParentNode.children(this)); | ||
return ParentNode.children(this); | ||
// return this._children || (this._children = ParentNode.children(this)); | ||
} | ||
@@ -320,6 +326,2 @@ | ||
get childNodes() { | ||
return this._childNodes || (this._childNodes = getChildNodes(this)); | ||
} | ||
/** | ||
@@ -346,3 +348,3 @@ * @param {Node} node | ||
appendChild(node) { | ||
invalidate(this); | ||
// invalidate(this); | ||
return this.insertBefore(node, this._end); | ||
@@ -357,3 +359,3 @@ } | ||
insertBefore(node, before) { | ||
invalidate(this); | ||
// invalidate(this); | ||
const _end = before || this._end; | ||
@@ -372,3 +374,3 @@ const {_prev} = _end; | ||
case DOCUMENT_FRAGMENT_NODE: { | ||
invalidate(node); | ||
// invalidate(node); | ||
let {firstChild, lastChild} = node; | ||
@@ -407,3 +409,3 @@ if (firstChild) { | ||
normalize() { | ||
let invalidated = false; | ||
let shouldInvalidate = false; | ||
let {_next, _end} = this; | ||
@@ -414,7 +416,7 @@ while (_next !== _end) { | ||
if (!_next.textContent) { | ||
invalidated = true; | ||
shouldInvalidate = true; | ||
_next.remove(); | ||
} | ||
else if (_prev && _prev.nodeType === TEXT_NODE) { | ||
invalidated = true; | ||
shouldInvalidate = true; | ||
_prev.textContent += _next.textContent; | ||
@@ -426,4 +428,3 @@ _next.remove(); | ||
} | ||
if (invalidated) | ||
invalidate(this); | ||
// if (shouldInvalidate) invalidate(this); | ||
} | ||
@@ -438,3 +439,2 @@ | ||
throw new Error('node is not a child'); | ||
invalidate(this); | ||
node.remove(); | ||
@@ -451,3 +451,3 @@ return node; | ||
const {_prev, _next} = getBoundaries(replaced); | ||
invalidate(this); | ||
// invalidate(this); | ||
replaced.remove(); | ||
@@ -454,0 +454,0 @@ node.remove(); |
@@ -56,5 +56,3 @@ import {Parser} from 'htmlparser2'; | ||
export const invalidate = element => { | ||
element._childNodes = element._children = null; | ||
}; | ||
// export const invalidate = $ => { $._childNodes = $._children = null; }; | ||
@@ -61,0 +59,0 @@ export const isVoidElement = ({localName, ownerDocument}) => { |
{ | ||
"name": "linkedom", | ||
"version": "0.1.16", | ||
"version": "0.1.17", | ||
"description": "A triple-linked lists based DOM", | ||
@@ -5,0 +5,0 @@ "main": "./cjs/index.js", |
1500718
148484
3767