Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

can-dom-mutate

Package Overview
Dependencies
Maintainers
9
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

can-dom-mutate - npm Package Compare versions

Comparing version 1.3.9 to 1.3.11

.idea/can-dom-mutate.iml

47

node/node-test.js

@@ -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();

11

node/node.js

@@ -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 () {

2

package.json
{
"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",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc