From f3dab1a3297e174c1954855a9e32d75f46d5bd21 Mon Sep 17 00:00:00 2001 From: Brian Stanback Date: Mon, 3 Apr 2017 10:18:53 -0700 Subject: [PATCH] Handle innerHTML --- src/undom.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/undom.js b/src/undom.js index a6d6f1b..3366da6 100644 --- a/src/undom.js +++ b/src/undom.js @@ -101,12 +101,28 @@ export default function undom() { set: val => { this.setAttribute('style', val); }, get: () => this.getAttribute('style') }); + Object.defineProperty(this, 'innerHTML', { + set: val => { + while (this.firstChild) { + this.removeChild(this.firstChild); + } + this._innerHTML = val; + }, + get: () => { return this._innerHTML; } + }); } get children() { return this.childNodes.filter(isElement); } + insertBefore(child, ref) { + super.insertBefore(child, ref); + if (this._innerHTML) { + this._innerHTML = ''; + } + } + setAttribute(key, value) { this.setAttributeNS(null, key, value); }