Skip to content

Commit

Permalink
Handle innerHTML
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanback committed Apr 3, 2017
1 parent f4d70bf commit 6587fc1
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/undom.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,24 @@ export default function undom() {
set: val => { this.setAttribute('style', val); },
get: () => this.getAttribute('style')
});
Object.defineProperty(this, 'innerHTML', {
set: val => { this.setAttribute('innerHTML', val); },
get: () => this.getAttribute('innerHTML')
});
}

get children() {
return this.childNodes.filter(isElement);
}

insertBefore(child, ref) {
super.insertBefore(child, ref);
let attr = findWhere(this.attributes, createAttributeFilter(null, 'innerHTML'));
if (attr) {
this.removeAttribute('innerHTML');
}
}

setAttribute(key, value) {
this.setAttributeNS(null, key, value);
}
Expand All @@ -121,6 +133,11 @@ export default function undom() {
let attr = findWhere(this.attributes, createAttributeFilter(ns, name));
if (!attr) this.attributes.push(attr = { ns, name });
attr.value = String(value);
if (name === 'innerHTML') {
while (this.firstChild) {
this.removeChild(this.firstChild);
}
}
}
getAttributeNS(ns, name) {
let attr = findWhere(this.attributes, createAttributeFilter(ns, name));
Expand Down

0 comments on commit 6587fc1

Please sign in to comment.