Skip to content

Commit

Permalink
applying pahen's patch (jsdom#48) which fixes jQuery errors when usin…
Browse files Browse the repository at this point in the history
…g level2
  • Loading branch information
tmpvar committed Oct 12, 2010
1 parent 047501e commit f3f04a4
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions lib/jsdom/level2/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ var testNamespaceName = function(ns, nsuri) {
if(ns.match(/[^0-9a-z\.:\-_]/i) !== null) {
throw new core.DOMException(core.INVALID_CHARACTER_ERR, ns);
}
if ((ns === 'xmlns' && nsuri !== "http://www.w3.org/2000/xmlns/") ||
if ((ns === 'xmlns' && nsuri !== "http://www.w3.org/2000/xmlns/") ||
(ns === "xml" && nsuri !== "http://www.w3.org/XML/1998/namespace") ||
ns.indexOf('::') > -1 ||
ns.indexOf('::') > -1 ||
nsuri === null ||
ns[ns.length-1] === ':' || // handle "namespace:"
ns[0] === ':' ||
ns[0] === ':' ||
ns.match(/.+:.+:/))
{
throw new core.DOMException(core.NAMESPACE_ERR);
Expand All @@ -27,7 +27,7 @@ var NAMESPACE_ERR = core.NAMESPACE_ERR = 14;
var INVALID_ACCESS_ERR = core.INVALID_ACCESS_ERR = 15;

core.DOMImplementation.prototype.createDocumentType = function(/* String */ qualifiedName,
/* String */ publicId,
/* String */ publicId,
/* String */ systemId)
{
testNamespaceName(qualifiedName);
Expand All @@ -38,7 +38,7 @@ core.DOMImplementation.prototype.createDocumentType = function(/* String */ qual
};

/**
Creates an XML Document object of the specified type with its document element.
Creates an XML Document object of the specified type with its document element.
HTML-only DOM implementations do not need to implement this method.
*/
core.DOMImplementation.prototype.createDocument = function(/* String */ namespaceURI,
Expand Down Expand Up @@ -87,7 +87,7 @@ core.Node.prototype.__defineSetter__("prefix", function(value) {
throw new core.DOMException(core.NAMESPACE_ERR);
}
testNamespaceName(value, this._namespaceURI);

this._prefix = value;
});

Expand All @@ -106,7 +106,7 @@ core.NamedNodeMap.prototype.getNamedItemNS = function(/* string */ namespaceURI,
{
var defaultNode = null;
return this._map(function(item) {

if (namespaceURI === item.namespaceURI)
{
if (item.localName === localName) {
Expand All @@ -131,8 +131,8 @@ core.AttrNodeMap.prototype.setNamedItem = function(/* Node */ arg) {
core.NamedNodeMap.prototype.setNamedItemNS = function(/* Node */ arg)
{
var owner = this._ownerDocument;
if (this.parentNode &&
this.parentNode.parentNode &&
if (this.parentNode &&
this.parentNode.parentNode &&
this.parentNode.parentNode.nodeType === owner.ENTITY_NODE)
{
throw new core.DOMException(core.NO_MODIFICATION_ALLOWED_ERR);
Expand All @@ -151,7 +151,7 @@ core.NamedNodeMap.prototype.setNamedItemNS = function(/* Node */ arg)
core.NamedNodeMap.prototype.removeNamedItemNS = function(/*string */ namespaceURI,
/* string */ localName)
{
if (this.parentNode &&
if (this.parentNode &&
this.parentNode.parentNode &&
this.parentNode.parentNode.nodeType === this._ownerDocument.ENTITY_NODE)
{
Expand Down Expand Up @@ -192,13 +192,13 @@ core.Element.prototype.getAttributeNS = function(/* string */ namespaceURI,
/* string */ localName)
{
var attr = this._attributes._map(function(attr) {
if (namespaceURI === attr.namespaceURI &&
if (namespaceURI === attr.namespaceURI &&
attr.localName === localName)
{
return true;
}
})[0];

return (attr) ? attr.nodeValue : null;
};

Expand All @@ -209,7 +209,7 @@ core.Element.prototype.setAttributeNS = function(/* string */ namespaceURI,

testNamespaceName(qualifiedName, namespaceURI);

if (qualifiedName.split(':').shift() === "xml" &&
if (qualifiedName.split(':').shift() === "xml" &&
namespaceURI !== "http://www.w3.org/XML/1998/namespace")
{
throw new core.DOMException(core.NAMESPACE_ERR);
Expand All @@ -230,7 +230,7 @@ core.Element.prototype.removeAttributeNS = function(/* string */ namespaceURI,
/* string */ localName)
{
var qualifiedName = this._attributes._map(function(attr) {
if (namespaceURI === attr.namespaceURI &&
if (namespaceURI === attr.namespaceURI &&
attr.localName === localName)
{
return true;
Expand All @@ -243,7 +243,7 @@ core.Element.prototype.getAttributeNodeNS = function(/* string */ namespaceURI,
/* string */ localName)
{
return this._attributes._map(function(attr) {
if (namespaceURI === attr.namespaceURI &&
if (namespaceURI === attr.namespaceURI &&
attr.localName === localName)
{
return true;
Expand All @@ -253,7 +253,7 @@ core.Element.prototype.getAttributeNodeNS = function(/* string */ namespaceURI,

core.Element.prototype.setAttributeNodeNS = function(/* Attr */ newAttr)
{
if (newAttr.ownerElement) {
if (newAttr.ownerElement) {
throw new core.DOMException(core.INUSE_ATTRIBUTE_ERR);
}

Expand All @@ -280,9 +280,9 @@ core.Element.prototype.getElementsByTagNameNS = function(/* String */ namespaceU
return false;
}

if (this.ownerDocument &&
this.ownerDocument.implementation &&
this.ownerDocument.implementation.hasFeature("DisableLiveLists"))
if (this.ownerDocument &&
this.ownerDocument.implementation &&
this.ownerDocument.implementation.hasFeature("DisableLiveLists"))
{
return core.mapDOMNodes(this, true, queryFunction);
} else {
Expand All @@ -295,10 +295,10 @@ core.Element.prototype.hasAttribute = function(/* string */name)
if (!this.attributes) {
return false;
}
return this.attributes().exists(name);
return this.attributes.exists(name);
};

core.Element.prototype.hasAttributeNS = function(/* string */namespaceURI,
core.Element.prototype.hasAttributeNS = function(/* string */namespaceURI,
/* string */localName)
{
if (!this._attributes ||
Expand All @@ -322,7 +322,7 @@ core.DocumentType.prototype.__defineGetter__("internalSubset", function() {
return this._internalSubset || null;
});

core.Document.prototype.importNode = function(/* Node */ importedNode,
core.Document.prototype.importNode = function(/* Node */ importedNode,
/* bool */ deep)
{
if (importedNode && importedNode.nodeType) {
Expand All @@ -331,7 +331,7 @@ core.Document.prototype.importNode = function(/* Node */ importedNode,
throw new core.DOMException(core.NOT_SUPPORTED_ERR);
}
}

var newNode = importedNode.cloneNode(deep);
newNode._ownerDocument = this;
newNode._ownerElement = null;
Expand All @@ -341,31 +341,31 @@ core.Document.prototype.importNode = function(/* Node */ importedNode,
return newNode;
};

core.Document.prototype.createElementNS = function(/* string */ namespaceURI,
core.Document.prototype.createElementNS = function(/* string */ namespaceURI,
/* string */ qualifiedName)
{
testNamespaceName(qualifiedName, namespaceURI);

var element = this.createElement(qualifiedName),
sploded = qualifiedName.split(':');

element.namespaceURI = namespaceURI;
element.qualifiedName = qualifiedName;

element._localName = sploded.pop();

if (sploded.length > 0) {
element.prefix = sploded.pop();
} else if (namespaceURI === "http://www.w3.org/2000/xmlns/") {
element.prefix = "xmlns";
} else if (namespaceURI === "http://www.w3.org/XML/1998/namespace") {
element.prefix = "xml";
}

return element;
};

core.Document.prototype.createAttributeNS = function(/* string */ namespaceURI,
core.Document.prototype.createAttributeNS = function(/* string */ namespaceURI,
/* string */ qualifiedName)
{
testNamespaceName(qualifiedName, namespaceURI);
Expand Down

0 comments on commit f3f04a4

Please sign in to comment.