Comparing version 0.1.19 to 0.1.20
'use strict'; | ||
const {ELEMENT_NODE, ELEMENT_NODE_END, ATTRIBUTE_NODE, TEXT_NODE, COMMENT_NODE} = require('./constants.js'); | ||
const {String, getNext, ignoreCase, isVoidElement, localCase, parseFromString} = require('./utils.js'); | ||
const {String, getNext, getPrev, ignoreCase, isVoidElement, localCase, parseFromString} = require('./utils.js'); | ||
@@ -142,3 +142,3 @@ const {NodeList} = require('./interfaces.js'); | ||
get previousSibling() { | ||
return this._prev; | ||
return getPrev(this); | ||
} | ||
@@ -145,0 +145,0 @@ |
@@ -72,3 +72,3 @@ 'use strict'; | ||
node.parentNode = node._prev = _end._next = null; | ||
// if (parentNode) invalidate(parentNode); | ||
// DO_NOT_REMOVE if (parentNode) invalidate(parentNode); | ||
} | ||
@@ -143,3 +143,3 @@ }; | ||
const append = (element, nodes) => { | ||
// invalidate(element); | ||
// DO_NOT_REMOVE invalidate(element); | ||
const {ownerDocument, _end} = element; | ||
@@ -208,3 +208,3 @@ for (const node of nodes) | ||
prepend(element, nodes) { | ||
// invalidate(element); | ||
// DO_NOT_REMOVE invalidate(element); | ||
const {ownerDocument, firstChild} = element; | ||
@@ -225,3 +225,3 @@ for (const node of nodes) | ||
replaceChildren(element, nodes) { | ||
// invalidate(element); | ||
// DO_NOT_REMOVE invalidate(element); | ||
let {_next, _end} = element; | ||
@@ -228,0 +228,0 @@ while (_next !== _end) { |
@@ -21,3 +21,4 @@ 'use strict'; | ||
getEnd, | ||
getNext | ||
getNext, | ||
getPrev | ||
} = require('./utils.js'); | ||
@@ -247,3 +248,3 @@ | ||
super(ownerDocument, localName, nodeType); | ||
// invalidate(this); | ||
// DO_NOT_REMOVE invalidate(this); | ||
} | ||
@@ -253,3 +254,3 @@ | ||
return getChildNodes(this); | ||
// return this._childNodes || (this._childNodes = getChildNodes(this)); | ||
// DO_NOT_REMOVE return this._childNodes || (this._childNodes = getChildNodes(this)); | ||
} | ||
@@ -260,3 +261,3 @@ | ||
return ParentNode.children(this); | ||
// return this._children || (this._children = ParentNode.children(this)); | ||
// DO_NOT_REMOVE return this._children || (this._children = ParentNode.children(this)); | ||
} | ||
@@ -351,3 +352,3 @@ | ||
appendChild(node) { | ||
// invalidate(this); | ||
// DO_NOT_REMOVE invalidate(this); | ||
return this.insertBefore(node, this._end); | ||
@@ -362,3 +363,3 @@ } | ||
insertBefore(node, before) { | ||
// invalidate(this); | ||
// DO_NOT_REMOVE invalidate(this); | ||
const _end = before || this._end; | ||
@@ -377,3 +378,3 @@ const {_prev} = _end; | ||
case DOCUMENT_FRAGMENT_NODE: { | ||
// invalidate(node); | ||
// DO_NOT_REMOVE invalidate(node); | ||
let {firstChild, lastChild} = node; | ||
@@ -429,3 +430,3 @@ if (firstChild) { | ||
} | ||
// if (shouldInvalidate) invalidate(this); | ||
// DO_NOT_REMOVE if (shouldInvalidate) invalidate(this); | ||
} | ||
@@ -451,3 +452,3 @@ | ||
const {_prev, _next} = getBoundaries(replaced); | ||
// invalidate(this); | ||
// DO_NOT_REMOVE invalidate(this); | ||
replaced.remove(); | ||
@@ -502,3 +503,3 @@ node.remove(); | ||
get previousSibling() { | ||
return this._prev; | ||
return getPrev(this); | ||
} | ||
@@ -505,0 +506,0 @@ |
@@ -7,3 +7,5 @@ 'use strict'; | ||
ELEMENT_NODE, | ||
ATTRIBUTE_NODE | ||
ATTRIBUTE_NODE, | ||
TEXT_NODE, | ||
COMMENT_NODE | ||
} = require('./constants.js'); | ||
@@ -58,3 +60,3 @@ | ||
const getEnd = node => node.nodeType === ELEMENT_NODE ? | ||
node._end : node; | ||
node._end : node; | ||
exports.getEnd = getEnd; | ||
@@ -69,2 +71,16 @@ | ||
const getPrev = ({_prev}) => { | ||
if (_prev) { | ||
switch (_prev.nodeType) { | ||
case ELEMENT_NODE_END: | ||
return _prev._start; | ||
case TEXT_NODE: | ||
case COMMENT_NODE: | ||
return _prev; | ||
} | ||
} | ||
return null; | ||
}; | ||
exports.getPrev = getPrev; | ||
const ignoreCase = ({ownerDocument}) => ownerDocument._mime.ignoreCase; | ||
@@ -71,0 +87,0 @@ exports.ignoreCase = ignoreCase; |
import {ELEMENT_NODE, ELEMENT_NODE_END, ATTRIBUTE_NODE, TEXT_NODE, COMMENT_NODE} from './constants.js'; | ||
import {String, getNext, ignoreCase, isVoidElement, localCase, parseFromString} from './utils.js'; | ||
import {String, getNext, getPrev, ignoreCase, isVoidElement, localCase, parseFromString} from './utils.js'; | ||
@@ -141,3 +141,3 @@ import {NodeList} from './interfaces.js'; | ||
get previousSibling() { | ||
return this._prev; | ||
return getPrev(this); | ||
} | ||
@@ -144,0 +144,0 @@ |
@@ -72,3 +72,3 @@ import { | ||
node.parentNode = node._prev = _end._next = null; | ||
// if (parentNode) invalidate(parentNode); | ||
// DO_NOT_REMOVE if (parentNode) invalidate(parentNode); | ||
} | ||
@@ -140,3 +140,3 @@ }; | ||
const append = (element, nodes) => { | ||
// invalidate(element); | ||
// DO_NOT_REMOVE invalidate(element); | ||
const {ownerDocument, _end} = element; | ||
@@ -205,3 +205,3 @@ for (const node of nodes) | ||
prepend(element, nodes) { | ||
// invalidate(element); | ||
// DO_NOT_REMOVE invalidate(element); | ||
const {ownerDocument, firstChild} = element; | ||
@@ -222,3 +222,3 @@ for (const node of nodes) | ||
replaceChildren(element, nodes) { | ||
// invalidate(element); | ||
// DO_NOT_REMOVE invalidate(element); | ||
let {_next, _end} = element; | ||
@@ -225,0 +225,0 @@ while (_next !== _end) { |
@@ -21,2 +21,3 @@ import { | ||
getNext, | ||
getPrev, | ||
// invalidate | ||
@@ -246,3 +247,3 @@ } from './utils.js'; | ||
super(ownerDocument, localName, nodeType); | ||
// invalidate(this); | ||
// DO_NOT_REMOVE invalidate(this); | ||
} | ||
@@ -252,3 +253,3 @@ | ||
return getChildNodes(this); | ||
// return this._childNodes || (this._childNodes = getChildNodes(this)); | ||
// DO_NOT_REMOVE return this._childNodes || (this._childNodes = getChildNodes(this)); | ||
} | ||
@@ -259,3 +260,3 @@ | ||
return ParentNode.children(this); | ||
// return this._children || (this._children = ParentNode.children(this)); | ||
// DO_NOT_REMOVE return this._children || (this._children = ParentNode.children(this)); | ||
} | ||
@@ -350,3 +351,3 @@ | ||
appendChild(node) { | ||
// invalidate(this); | ||
// DO_NOT_REMOVE invalidate(this); | ||
return this.insertBefore(node, this._end); | ||
@@ -361,3 +362,3 @@ } | ||
insertBefore(node, before) { | ||
// invalidate(this); | ||
// DO_NOT_REMOVE invalidate(this); | ||
const _end = before || this._end; | ||
@@ -376,3 +377,3 @@ const {_prev} = _end; | ||
case DOCUMENT_FRAGMENT_NODE: { | ||
// invalidate(node); | ||
// DO_NOT_REMOVE invalidate(node); | ||
let {firstChild, lastChild} = node; | ||
@@ -428,3 +429,3 @@ if (firstChild) { | ||
} | ||
// if (shouldInvalidate) invalidate(this); | ||
// DO_NOT_REMOVE if (shouldInvalidate) invalidate(this); | ||
} | ||
@@ -450,3 +451,3 @@ | ||
const {_prev, _next} = getBoundaries(replaced); | ||
// invalidate(this); | ||
// DO_NOT_REMOVE invalidate(this); | ||
replaced.remove(); | ||
@@ -500,3 +501,3 @@ node.remove(); | ||
get previousSibling() { | ||
return this._prev; | ||
return getPrev(this); | ||
} | ||
@@ -503,0 +504,0 @@ |
@@ -6,3 +6,5 @@ import {Parser} from 'htmlparser2'; | ||
ELEMENT_NODE, | ||
ATTRIBUTE_NODE | ||
ATTRIBUTE_NODE, | ||
TEXT_NODE, | ||
COMMENT_NODE | ||
} from './constants.js'; | ||
@@ -54,3 +56,3 @@ | ||
export const getEnd = node => node.nodeType === ELEMENT_NODE ? | ||
node._end : node; | ||
node._end : node; | ||
@@ -63,2 +65,15 @@ export const getNext = ({_next}) => { | ||
export const getPrev = ({_prev}) => { | ||
if (_prev) { | ||
switch (_prev.nodeType) { | ||
case ELEMENT_NODE_END: | ||
return _prev._start; | ||
case TEXT_NODE: | ||
case COMMENT_NODE: | ||
return _prev; | ||
} | ||
} | ||
return null; | ||
}; | ||
export const ignoreCase = ({ownerDocument}) => ownerDocument._mime.ignoreCase; | ||
@@ -65,0 +80,0 @@ |
{ | ||
"name": "linkedom", | ||
"version": "0.1.19", | ||
"version": "0.1.20", | ||
"description": "A triple-linked lists based DOM", | ||
@@ -5,0 +5,0 @@ "main": "./cjs/index.js", |
@@ -5,3 +5,2 @@ # TODO | ||
- [ ] `document.createTreeWalker` utility | ||
- [ ] `element.style` special accessor case | ||
@@ -8,0 +7,0 @@ |
1510299
4160