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

can-attribute-observable

Package Overview
Dependencies
Maintainers
10
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

can-attribute-observable - npm Package Compare versions

Comparing version 2.0.0-pre.1 to 2.0.0

27

behaviors-test.js

@@ -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");
});
});

14

behaviors.js

@@ -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 @@ };

2

package.json
{
"name": "can-attribute-observable",
"version": "2.0.0-pre.1",
"version": "2.0.0",
"description": "Create observables from HTML attributes.",

@@ -5,0 +5,0 @@ "main": "can-attribute-observable",

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