jsdom
Advanced tools
Comparing version 0.3.3 to 0.3.4
@@ -247,17 +247,26 @@ var http = require('http'), | ||
cs = new CSSStyleDeclaration(), | ||
forEach = Array.prototype.forEach, | ||
selectors, matched; | ||
forEach = Array.prototype.forEach; | ||
function setPropertiesFromRule(rule) { | ||
var selectors = rule.selectorText.split(/\s*,\s*/); | ||
var matched = false; | ||
selectors.forEach(function (selectorText) { | ||
if (!matched && matchesDontThrow(node, selectorText)) { | ||
matched = true; | ||
forEach.call(rule.style, function (property) { | ||
cs.setProperty(property, rule.style.getPropertyValue(property), rule.style.getPropertyPriority(property)); | ||
}); | ||
} | ||
}); | ||
} | ||
forEach.call(node.ownerDocument.styleSheets, function (sheet) { | ||
forEach.call(sheet.cssRules, function (ruleSet) { | ||
selectors = ruleSet.selectorText.split(/\s*,\s*/); | ||
matched = false; | ||
selectors.forEach(function (selectorText) { | ||
if (!matched && matchesDontThrow(node, selectorText)) { | ||
matched = true; | ||
forEach.call(ruleSet.style, function (property) { | ||
cs.setProperty(property, ruleSet.style.getPropertyValue(property), ruleSet.style.getPropertyPriority(property)); | ||
}); | ||
forEach.call(sheet.cssRules, function (rule) { | ||
if (rule.media) { | ||
if (Array.prototype.indexOf.call(rule.media, 'screen') !== -1) { | ||
forEach.call(rule.cssRules, setPropertiesFromRule); | ||
} | ||
}); | ||
} else { | ||
setPropertiesFromRule(rule); | ||
} | ||
}); | ||
@@ -264,0 +273,0 @@ }); |
{ | ||
"name": "jsdom", | ||
"version": "0.3.3", | ||
"version": "0.3.4", | ||
"description": "A JavaScript implementation of the W3C DOM", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
18
test.js
"use strict"; | ||
var assert = require("assert"); | ||
var jsdom = require("./lib/jsdom").jsdom; | ||
//var document = jsdom('<html><head></head><body><select><option value="">Nothing</option><option value="1">1</option><option value="2">2</option><option value="3">3</option></select><img src="3" /></body></html>'); | ||
var document = jsdom('<html><head></head><body><div><p>stuff</p></div></body></html>'); | ||
var window = document.createWindow(); | ||
var jsdom = require("./lib/jsdom"); | ||
var cssom = require("cssom"); | ||
console.log(document.querySelector("div\tp")); | ||
console.log(cssom.parse(require("fs").readFileSync('test.css', 'utf-8'))); | ||
jsdom.env({ | ||
html: '<html><head><style>' + require("fs").readFileSync('test.css') + '</style></head><body></body></html>', | ||
config: { | ||
ProcessExternalResources: ["script", "link"] | ||
}, | ||
done: function (errors, window) { | ||
window.getComputedStyle(window.document.body); | ||
} | ||
}); |
343986
27
10008
8