can-attribute-observable
Advanced tools
Comparing version 1.2.6 to 1.2.7
@@ -168,2 +168,29 @@ var testHelpers = require("../test/helpers"); | ||
}); | ||
testIfRealDocument("should use setAttributeNS instead of setAttribute for namespaced-attributes", function(assert) { | ||
var svgNamespaceURI = "http://www.w3.org/2000/svg"; | ||
var xlinkHrefAttrNamespaceURI = "http://www.w3.org/1999/xlink"; | ||
var xlinkHrefAttr = "xlink:href"; | ||
var origValue = "icons.svg#logo"; | ||
var newValue = "icons.svg#pointDown"; | ||
var svg = document.createElementNS(svgNamespaceURI, "svg"); | ||
var svgUse = document.createElementNS(svgNamespaceURI, "use"); | ||
svgUse.setAttributeNS(xlinkHrefAttrNamespaceURI, xlinkHrefAttr, origValue); | ||
svg.appendChild(svgUse); | ||
var ta = this.fixture; | ||
ta.appendChild(svg); | ||
var obs = new AttributeObservable(svgUse, xlinkHrefAttr); | ||
// test get | ||
var origValueNS = obs.get(xlinkHrefAttr); | ||
assert.equal(origValueNS, origValue, "get should match origValue"); | ||
// test set | ||
obs.set(newValue); | ||
assert.equal(svgUse.getAttributeNS(xlinkHrefAttrNamespaceURI, "href"), newValue, "getAttributeNS() should match newValue"); | ||
assert.equal(svgUse.getAttribute(xlinkHrefAttr), newValue, "getAttribute() should match newValue"); | ||
}); | ||
}); |
@@ -13,2 +13,10 @@ 'use strict'; | ||
var xmlnsAttrNamespaceURI = "http://www.w3.org/2000/xmlns/"; | ||
var xlinkHrefAttrNamespaceURI = "http://www.w3.org/1999/xlink"; | ||
var attrsNamespacesURI = { | ||
'xmlns': xmlnsAttrNamespaceURI, | ||
'xlink:href': xlinkHrefAttrNamespaceURI | ||
}; | ||
var formElements = {"INPUT": true, "TEXTAREA": true, "SELECT": true, "BUTTON": true}, | ||
@@ -500,3 +508,7 @@ // Used to convert values to strings. | ||
set: function(val) { | ||
domMutateNode.setAttribute.call(this, attrName, val); | ||
if (attrsNamespacesURI[attrName]) { | ||
domMutateNode.setAttributeNS.call(this, attrsNamespacesURI[attrName], attrName, val); | ||
} else { | ||
domMutateNode.setAttribute.call(this, attrName, val); | ||
} | ||
} | ||
@@ -503,0 +515,0 @@ }; |
{ | ||
"name": "can-attribute-observable", | ||
"version": "1.2.6", | ||
"version": "1.2.7", | ||
"description": "Create observables from HTML attributes.", | ||
@@ -37,3 +37,3 @@ "main": "can-attribute-observable", | ||
"can-dom-events": "^1.1.2", | ||
"can-dom-mutate": "^1.0.3", | ||
"can-dom-mutate": "^1.3.11", | ||
"can-event-dom-radiochange": "^2.1.0", | ||
@@ -40,0 +40,0 @@ "can-globals": "^1.0.1", |
Sorry, the diff of this file is not supported yet
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
56580
25
1159
Updatedcan-dom-mutate@^1.3.11