Comparing version 0.1.10 to 0.1.11
@@ -25,5 +25,6 @@ 'use strict'; | ||
toString() { | ||
return `${this.name}="${escape(this.value)}"`; | ||
const {name, value} = this; | ||
return value ? `${name}="${escape(this.value)}"` : name; | ||
} | ||
} | ||
exports.Attr = Attr |
@@ -132,3 +132,3 @@ 'use strict'; | ||
set outerHTML(html) { | ||
const template = document.createElement('<>'); | ||
const template = this.ownerDocument.createElement('<>'); | ||
template.innerHTML = html; | ||
@@ -200,6 +200,8 @@ this.parentNode.replaceChild(template.firstElementChild, this); | ||
if (_next === attribute) { | ||
const {_prev, _next} = attribute; | ||
const {_prev, _next, name} = attribute; | ||
_prev._next = _next; | ||
_next._prev = _prev; | ||
attribute.ownerElement = attribute._prev = attribute._next = null; | ||
if (name === 'class') | ||
this._classList = null; | ||
return; | ||
@@ -228,2 +230,4 @@ } | ||
this._next = _next._prev = attribute; | ||
if (attribute.name === 'class') | ||
this.className = attribute.value; | ||
} | ||
@@ -240,11 +244,2 @@ return previously; | ||
/** | ||
* @deprecated | ||
* @param {string} namespace | ||
* @param {string} name | ||
*/ | ||
hasAttributeNS(_, name) { | ||
return this.hasAttribute(name); | ||
} | ||
hasAttributes() { | ||
@@ -268,12 +263,2 @@ return this._next.nodeType === ATTRIBUTE_NODE; | ||
/** | ||
* @deprecated | ||
* @param {string} namespace | ||
* @param {string} name | ||
* @returns {string?} | ||
*/ | ||
getAttributeNS(_, name) { | ||
return this.getAttribute(name); | ||
} | ||
/** | ||
* @param {string} name | ||
@@ -293,12 +278,3 @@ */ | ||
/** | ||
* @deprecated | ||
* @param {string} namespace | ||
* @param {string} name | ||
*/ | ||
removeAttributeNS(_, name) { | ||
this.removeAttribute(name); | ||
} | ||
/** | ||
* @param {string} name | ||
* @param {string|any} value casted, if not string | ||
@@ -318,12 +294,2 @@ */ | ||
/** | ||
* @deprecated | ||
* @param {string} namespace | ||
* @param {string} name | ||
* @param {string|any} value casted, if not string | ||
*/ | ||
setAttributeNS(_, name, value) { | ||
this.setAttribute(name, value); | ||
} | ||
/** | ||
* @param {string} name | ||
@@ -396,11 +362,2 @@ * @param {boolean?} force | ||
/** | ||
* @deprecated | ||
* @param {string} namespace | ||
* @param {string} name | ||
*/ | ||
getElementsByTagNameNS(_, name) { | ||
return this.getElementsByTagName(name); | ||
} | ||
/** | ||
* @param {string} className | ||
@@ -430,3 +387,54 @@ */ | ||
} | ||
/* c8 ignore start */ | ||
/** | ||
* @deprecated | ||
* @param {string} namespace | ||
* @param {string} name | ||
* @returns {string?} | ||
*/ | ||
getAttributeNS(_, name) { | ||
return this.getAttribute(name); | ||
} | ||
/** | ||
* @deprecated | ||
* @param {string} namespace | ||
* @param {string} name | ||
*/ | ||
getElementsByTagNameNS(_, name) { | ||
return this.getElementsByTagName(name); | ||
} | ||
/** | ||
* @deprecated | ||
* @param {string} namespace | ||
* @param {string} name | ||
*/ | ||
hasAttributeNS(_, name) { | ||
return this.hasAttribute(name); | ||
} | ||
/** | ||
* @deprecated | ||
* @param {string} namespace | ||
* @param {string} name | ||
*/ | ||
removeAttributeNS(_, name) { | ||
this.removeAttribute(name); | ||
} | ||
/** | ||
* @deprecated | ||
* @param {string} namespace | ||
* @param {string} name | ||
* @param {string|any} value casted, if not string | ||
*/ | ||
setAttributeNS(_, name, value) { | ||
this.setAttribute(name, value); | ||
} | ||
/* c8 ignore end */ | ||
} | ||
exports.Element = Element |
@@ -24,4 +24,5 @@ import {escape} from 'html-escaper'; | ||
toString() { | ||
return `${this.name}="${escape(this.value)}"`; | ||
const {name, value} = this; | ||
return value ? `${name}="${escape(this.value)}"` : name; | ||
} | ||
} |
@@ -131,3 +131,3 @@ import {ELEMENT_NODE, ELEMENT_NODE_END, ATTRIBUTE_NODE, TEXT_NODE, COMMENT_NODE} from './constants.js'; | ||
set outerHTML(html) { | ||
const template = document.createElement('<>'); | ||
const template = this.ownerDocument.createElement('<>'); | ||
template.innerHTML = html; | ||
@@ -199,6 +199,8 @@ this.parentNode.replaceChild(template.firstElementChild, this); | ||
if (_next === attribute) { | ||
const {_prev, _next} = attribute; | ||
const {_prev, _next, name} = attribute; | ||
_prev._next = _next; | ||
_next._prev = _prev; | ||
attribute.ownerElement = attribute._prev = attribute._next = null; | ||
if (name === 'class') | ||
this._classList = null; | ||
return; | ||
@@ -227,2 +229,4 @@ } | ||
this._next = _next._prev = attribute; | ||
if (attribute.name === 'class') | ||
this.className = attribute.value; | ||
} | ||
@@ -239,11 +243,2 @@ return previously; | ||
/** | ||
* @deprecated | ||
* @param {string} namespace | ||
* @param {string} name | ||
*/ | ||
hasAttributeNS(_, name) { | ||
return this.hasAttribute(name); | ||
} | ||
hasAttributes() { | ||
@@ -267,12 +262,2 @@ return this._next.nodeType === ATTRIBUTE_NODE; | ||
/** | ||
* @deprecated | ||
* @param {string} namespace | ||
* @param {string} name | ||
* @returns {string?} | ||
*/ | ||
getAttributeNS(_, name) { | ||
return this.getAttribute(name); | ||
} | ||
/** | ||
* @param {string} name | ||
@@ -292,12 +277,3 @@ */ | ||
/** | ||
* @deprecated | ||
* @param {string} namespace | ||
* @param {string} name | ||
*/ | ||
removeAttributeNS(_, name) { | ||
this.removeAttribute(name); | ||
} | ||
/** | ||
* @param {string} name | ||
* @param {string|any} value casted, if not string | ||
@@ -317,12 +293,2 @@ */ | ||
/** | ||
* @deprecated | ||
* @param {string} namespace | ||
* @param {string} name | ||
* @param {string|any} value casted, if not string | ||
*/ | ||
setAttributeNS(_, name, value) { | ||
this.setAttribute(name, value); | ||
} | ||
/** | ||
* @param {string} name | ||
@@ -395,11 +361,2 @@ * @param {boolean?} force | ||
/** | ||
* @deprecated | ||
* @param {string} namespace | ||
* @param {string} name | ||
*/ | ||
getElementsByTagNameNS(_, name) { | ||
return this.getElementsByTagName(name); | ||
} | ||
/** | ||
* @param {string} className | ||
@@ -429,2 +386,53 @@ */ | ||
} | ||
/* c8 ignore start */ | ||
/** | ||
* @deprecated | ||
* @param {string} namespace | ||
* @param {string} name | ||
* @returns {string?} | ||
*/ | ||
getAttributeNS(_, name) { | ||
return this.getAttribute(name); | ||
} | ||
/** | ||
* @deprecated | ||
* @param {string} namespace | ||
* @param {string} name | ||
*/ | ||
getElementsByTagNameNS(_, name) { | ||
return this.getElementsByTagName(name); | ||
} | ||
/** | ||
* @deprecated | ||
* @param {string} namespace | ||
* @param {string} name | ||
*/ | ||
hasAttributeNS(_, name) { | ||
return this.hasAttribute(name); | ||
} | ||
/** | ||
* @deprecated | ||
* @param {string} namespace | ||
* @param {string} name | ||
*/ | ||
removeAttributeNS(_, name) { | ||
this.removeAttribute(name); | ||
} | ||
/** | ||
* @deprecated | ||
* @param {string} namespace | ||
* @param {string} name | ||
* @param {string|any} value casted, if not string | ||
*/ | ||
setAttributeNS(_, name, value) { | ||
this.setAttribute(name, value); | ||
} | ||
/* c8 ignore end */ | ||
} |
{ | ||
"name": "linkedom", | ||
"version": "0.1.10", | ||
"version": "0.1.11", | ||
"description": "A triple-linked lists based DOM", | ||
@@ -5,0 +5,0 @@ "main": "./cjs/index.js", |
103288
3447