can-dom-mutate
Advanced tools
Comparing version 1.3.9 to 1.3.11
@@ -81,2 +81,22 @@ var unit = require('steal-qunit'); | ||
QUnit.test('setAttributeNS should not call domMutate.dispatchNodeAttributeChange', function (assert) { | ||
var svgNamespaceURI = "http://www.w3.org/2000/svg"; | ||
var xlinkHrefAttrNamespaceURI = "http://www.w3.org/1999/xlink"; | ||
var xlinkHrefAttr = "xlink:href"; | ||
var origValue = "node/icons.svg#circle"; | ||
var newValue = "node/icons.svg#triangle"; | ||
var svg = document.createElementNS(svgNamespaceURI, "svg"); | ||
var svgUse = document.createElementNS(svgNamespaceURI, "use"); | ||
svgUse.setAttributeNS(xlinkHrefAttrNamespaceURI, xlinkHrefAttr, origValue); | ||
svg.appendChild(svgUse); | ||
var undo = neverCall(assert, domMutate, 'dispatchNodeAttributeChange'); | ||
node.setAttributeNS.call(svgUse, xlinkHrefAttrNamespaceURI, xlinkHrefAttr, newValue); | ||
undo(); | ||
assert.equal(svgUse.getAttribute(xlinkHrefAttr), newValue, 'Attribute should be set'); | ||
}); | ||
QUnit.test('removeAttribute should not call domMutate.dispatchNodeAttributeChange', function (assert) { | ||
@@ -254,2 +274,29 @@ var element = document.createElement('div'); | ||
QUnit.test('setAttributeNS should call domMutate.dispatchNodeAttributeChange', function (assert) { | ||
var done = assert.async(); | ||
var svgNamespaceURI = "http://www.w3.org/2000/svg"; | ||
var xlinkHrefAttrNamespaceURI = "http://www.w3.org/1999/xlink"; | ||
var xlinkHrefAttr = "xlink:href"; | ||
var origValue = "node/icons.svg#circle"; | ||
var newValue = "node/icons.svg#triangle"; | ||
var svg = document.createElementNS(svgNamespaceURI, "svg"); | ||
var svgUse = document.createElementNS(svgNamespaceURI, "use"); | ||
svgUse.setAttributeNS(xlinkHrefAttrNamespaceURI, xlinkHrefAttr, origValue); | ||
svg.appendChild(svgUse); | ||
var undo = mock(domMutate, 'dispatchNodeAttributeChange', function (node, attributeName, oldAttributeValue, callback) { | ||
assert.equal(node, svgUse, 'Should pass the element whose attribute is changing'); | ||
assert.equal(attributeName, xlinkHrefAttr, 'Should pass the changed attribute name'); | ||
assert.equal(oldAttributeValue, origValue, 'Should pass the old attribute value'); | ||
assert.equal(callback, undefined, 'Should not pass a callback'); | ||
assert.equal(svgUse.getAttribute(xlinkHrefAttr), newValue, 'Node should have the new attribute value'); | ||
undo(); | ||
done(); | ||
}); | ||
node.setAttributeNS.call(svgUse, xlinkHrefAttrNamespaceURI, xlinkHrefAttr, newValue); | ||
}); | ||
QUnit.test('removeAttribute should call domMutate.dispatchNodeAttributeChange', function (assert) { | ||
@@ -256,0 +303,0 @@ var done = assert.async(); |
@@ -43,2 +43,11 @@ 'use strict'; | ||
}, | ||
setAttributeNS: function (namespace, name, value) { | ||
var oldAttributeValue = this.getAttribute(name); | ||
var result = this.setAttributeNS(namespace, name, value); | ||
var newAttributeValue = this.getAttribute(name); | ||
if (oldAttributeValue !== newAttributeValue) { | ||
domMutate.dispatchNodeAttributeChange(this, name, oldAttributeValue); | ||
} | ||
return result; | ||
}, | ||
removeAttribute: function (name) { | ||
@@ -73,3 +82,3 @@ var oldAttributeValue = this.getAttribute(name); | ||
var normal = {}; | ||
var nodeMethods = ['appendChild', 'insertBefore', 'removeChild', 'replaceChild', 'setAttribute', 'removeAttribute']; | ||
var nodeMethods = ['appendChild', 'insertBefore', 'removeChild', 'replaceChild', 'setAttribute', 'setAttributeNS', 'removeAttribute']; | ||
nodeMethods.forEach(function (methodName) { | ||
@@ -76,0 +85,0 @@ normal[methodName] = function () { |
{ | ||
"name": "can-dom-mutate", | ||
"description": "Dispatch and listen for DOM mutations", | ||
"version": "1.3.9", | ||
"version": "1.3.11", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "DoneJS Team", |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 2 instances in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
30
0
0
1
75959
1452