Comparing version 0.6.1 to 0.6.2
@@ -635,4 +635,3 @@ var http = require('http'), | ||
if (!this._parentWindow) { | ||
var window = exports.windowAugmentation(dom, {document: this, url: this.URL}); | ||
this._parentWindow = window.getGlobal(); | ||
this.parentWindow = exports.windowAugmentation(dom, {document: this, url: this.URL}); | ||
} | ||
@@ -643,2 +642,11 @@ return this._parentWindow; | ||
dom.Document.prototype.__defineSetter__('parentWindow', function(window) { | ||
// Contextify does not support getters and setters, so we have to set them | ||
// on the original object instead. | ||
window._frame = function (name, frame) { | ||
if (typeof frame === 'undefined') { | ||
delete window[name]; | ||
} else { | ||
window.__defineGetter__(name, function () { return frame.contentWindow; }); | ||
} | ||
}; | ||
this._parentWindow = window.getGlobal(); | ||
@@ -645,0 +653,0 @@ }); |
@@ -1191,21 +1191,3 @@ /* | ||
nodeType : DOCUMENT_NODE, | ||
_elementBuilders : { | ||
canvas : function(document, tagName) { | ||
var element = new core.Element(document, tagName), | ||
canvas; | ||
// require node-canvas and catch the error if it blows up | ||
try { | ||
canvas = new (require('canvas'))(0,0); | ||
for (var attr in element) { | ||
if (!canvas[attr]) { | ||
canvas[attr] = element[attr]; | ||
} | ||
} | ||
return canvas; | ||
} catch (e) { | ||
return element; | ||
} | ||
} | ||
}, | ||
_elementBuilders : { }, | ||
_defaultElementBuilder: function(document, tagName) { | ||
@@ -1212,0 +1194,0 @@ return new core.Element(document, tagName); |
@@ -18,2 +18,24 @@ var core = require("./core").dom.level2.core, | ||
// TODO its own package? Pull request to Node? | ||
function resolveHref(baseUrl, href) { | ||
// When switching protocols, the path doesn't get canonicalized (i.e. .s and ..s are still left): | ||
// https://github.com/joyent/node/issues/5453 | ||
var intermediate = URL.resolve(baseUrl, href); | ||
// This canonicalizes the path, at the cost of overwriting the hash. | ||
var nextStep = URL.resolve(intermediate, '#'); | ||
// So, insert the hash back in, if there was one. | ||
var parsed = URL.parse(intermediate); | ||
var fixed = nextStep.slice(0, -1) + (parsed.hash || ''); | ||
// Finally, fix file:/// URLs on Windows, where Node removes their drive letters: | ||
// https://github.com/joyent/node/issues/5452 | ||
if (/^file\:\/\/\/[a-z]\:\//i.test(baseUrl) && /^file\:\/\/\//.test(fixed) && !/^file\:\/\/\/[a-z]\:\//i.test(fixed)) { | ||
fixed = fixed.replace(/^file\:\/\/\//, baseUrl.substring(0, 11)); | ||
} | ||
return fixed; | ||
} | ||
core.resourceLoader = { | ||
@@ -70,7 +92,10 @@ load: function(element, href, callback) { | ||
baseUrl: function(document) { | ||
var baseElements = document.getElementsByTagName('base'), | ||
baseUrl = document.URL; | ||
var baseElements = document.getElementsByTagName('base'); | ||
var baseUrl = document.URL; | ||
if (baseElements.length > 0) { | ||
baseUrl = baseElements.item(0).href || baseUrl; | ||
var baseHref = baseElements.item(0).href; | ||
if (baseHref) { | ||
baseUrl = resolveHref(baseUrl, baseHref); | ||
} | ||
} | ||
@@ -83,7 +108,4 @@ | ||
// lets resolve to an empty string (nulls are not expected farther up) | ||
if(href === null) | ||
if (href === null) { | ||
return ''; | ||
if (href.match(/^\w+:\/\//)) { | ||
return href; | ||
} | ||
@@ -93,12 +115,3 @@ | ||
// See RFC 2396 section 3 for this weirdness. URLs without protocol | ||
// have their protocol default to the current one. | ||
// http://www.ietf.org/rfc/rfc2396.txt | ||
if (href.match(/^\/\//)) { | ||
return baseUrl ? baseUrl.match(/^(\w+:)\/\//)[1] + href : null; | ||
} else if (!href.match(/^\/[^\/]/)) { | ||
href = href.replace(/^\//, ""); | ||
} | ||
return URL.resolve(baseUrl, href); | ||
return resolveHref(baseUrl, href); | ||
}, | ||
@@ -216,2 +229,7 @@ download: function(url, referrer, callback) { | ||
var el = new elem(doc, s); | ||
if (def.elementBuilder) { | ||
return def.elementBuilder(el, doc, s); | ||
} | ||
return el; | ||
@@ -1175,3 +1193,17 @@ }; | ||
'align' | ||
] | ||
], | ||
elementBuilder: function (element) { | ||
// require node-canvas and catch the error if it blows up | ||
try { | ||
var canvas = new (require('canvas'))(0,0); | ||
for (var attr in element) { | ||
if (!canvas[attr]) { | ||
canvas[attr] = element[attr]; | ||
} | ||
} | ||
return canvas; | ||
} catch (e) { | ||
return element; | ||
} | ||
} | ||
}); | ||
@@ -1832,10 +1864,14 @@ | ||
proto: { | ||
setAttribute: function(name, value) { | ||
core.HTMLElement.prototype.setAttribute.call(this, name, value); | ||
_attrModified: function(name, value, oldVal) { | ||
core.HTMLElement.prototype._attrModified.call(this, name, value, oldVal); | ||
var self = this; | ||
if (name === 'name') { | ||
// Remove named frame access. | ||
if (oldVal) { | ||
this._ownerDocument.parentWindow._frame(oldVal); | ||
} | ||
// Set up named frame access. | ||
this._ownerDocument.parentWindow.__defineGetter__(value, function () { | ||
return self.contentWindow; | ||
}); | ||
if (value) { | ||
this._ownerDocument.parentWindow._frame(value, this); | ||
} | ||
} else if (name === 'src') { | ||
@@ -1842,0 +1878,0 @@ // Page we don't fetch the page until the node is inserted. This at |
{ | ||
"name": "jsdom", | ||
"version": "0.6.1", | ||
"version": "0.6.2", | ||
"description": "A JavaScript implementation of the W3C DOM", | ||
@@ -74,3 +74,4 @@ "keywords": ["dom", "w3c", "html"], | ||
"nodeunit": "~0.8.0", | ||
"optimist": "*" | ||
"optimist": "*", | ||
"urlmaster": ">=0.2.15" | ||
}, | ||
@@ -77,0 +78,0 @@ "directories": { |
@@ -281,3 +281,3 @@ # jsdom | ||
level2/core 283/283 100% | ||
level2/html 705/705 100% | ||
level2/html 706/706 100% | ||
level2/style 14/14 100% | ||
@@ -289,3 +289,3 @@ level2/extra 4/4 100% | ||
window/script 10/10 100% | ||
window/frame 14/14 100% | ||
window/frame 16/16 100% | ||
sizzle/index 14/14 100% | ||
@@ -298,3 +298,3 @@ jsdom/index 88/88 100% | ||
------------------------------------------------------ | ||
TOTALS: 0/2600 failed; 100% success | ||
TOTALS: 0/2603 failed; 100% success | ||
``` | ||
@@ -301,0 +301,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
349017
10132
3