diff --git a/CHANGELOG.md b/CHANGELOG.md index 65857d0..b20d9bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # domino x.x.x (not yet released) +# domino 1.0.22 (26 Jan 2016) +* Prevent TypeError due to undefined property when parsing styles. (#69) + # domino 1.0.21 (23 Dec 2015) * Improve performance when adding nodes with duplicate IDs. (#60) * Be more careful about setting prototype to `null` when using diff --git a/lib/CSSStyleDeclaration.js b/lib/CSSStyleDeclaration.js index f7cdd42..840f90b 100644 --- a/lib/CSSStyleDeclaration.js +++ b/lib/CSSStyleDeclaration.js @@ -13,7 +13,7 @@ function CSSStyleDeclaration(elt) { // {"margin-left":"5px", "border-style":"solid"} function parseStyles(s) { var parser = new parserlib.css.Parser(); - var result = {}; + var result = { important: {} }; parser.addListener("property", function(e) { if (e.invalid) return; // Skip errors result[e.property.text] = e.value.text; diff --git a/package.json b/package.json index f9c3f74..4d0a695 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "domino", - "version": "1.0.21-git", + "version": "1.0.22", "author": "Felix Gnass ", "description": "Server-side DOM implementation based on Mozilla's dom.js", "homepage": "https://github.com/fgnass/domino", diff --git a/test/domino.js b/test/domino.js index 8e7445e..9f5c177 100644 --- a/test/domino.js +++ b/test/domino.js @@ -540,3 +540,11 @@ exports.contains = function() { nodeList[0].contains(nodeList[1]).should.equal(false); nodeList[1].contains(nodeList[0]).should.equal(false); }; + +exports.parseImportant = function() { + var html = '

foo

'; + var doc = domino.createDocument(html); + var p = doc.querySelector('p'); + p.style.fontFamily.should.equal('sans-serif'); + p.style.textDecoration.should.equal('none'); +};