Skip to content

Commit

Permalink
Rebuild css rules on text node changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebmaster committed Oct 5, 2014
1 parent d14c3a8 commit 637aca4
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/jsdom/level2/style.js
Expand Up @@ -259,6 +259,20 @@ html.HTMLStyleElement._init = function() {
});
evaluateStylesheet.call(this, content, this.sheet, this._ownerDocument.URL);
});

this.addEventListener('DOMNodeInserted', function () {
if (this.type && this.type !== 'text/css') {
//console.log('bad type: ' + this.type)
return;
}
var content = '';
Array.prototype.forEach.call(this.childNodes, function (child) {
if (child.nodeType === child.TEXT_NODE) { // text node
content += child.nodeValue;
}
});
evaluateStylesheet.call(this, content, this.sheet, this._ownerDocument.URL);
});
};
defineGetter(html.HTMLStyleElement.prototype, 'sheet', getOrCreateSheet);

Expand Down

0 comments on commit 637aca4

Please sign in to comment.