Skip to content

Commit

Permalink
support passing DOM objects directly to DOMElement::setContent()
Browse files Browse the repository at this point in the history
  • Loading branch information
CompSciFutures committed Feb 1, 2016
1 parent cc902b8 commit 776a0bf
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions dom-renderers/DOMRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,19 @@ DOMRenderer.prototype.setContent = function setContent(content) {
this._target.element.firstChild
);
}
this._target.content.innerHTML = content;
if ( typeof content === 'object') {
if ( !(
(window.HTMLElement && content instanceof window.HTMLElement) ||
(window.CharacterData && content instanceof window.CharacterData) ||
(window.Element && content instanceof window.Element) ||
(window.EventTarget && content instanceof window.EventTarget)
) )
throw new Error("content must be a DOM object or string: " + content);
this._target.content.innerHTML = "";
this._target.content.appendChild(content);
}
else
this._target.content.innerHTML = content;
}


Expand All @@ -629,7 +641,6 @@ DOMRenderer.prototype.setContent = function setContent(content) {
);
};


/**
* Sets the passed in transform matrix (world space). Inverts the parent's world
* transform.
Expand Down

0 comments on commit 776a0bf

Please sign in to comment.