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

can-attribute-observable

Package Overview
Dependencies
Maintainers
3
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 0.1.0 to 0.2.0

17

behaviors.js

@@ -422,7 +422,9 @@ 'use strict';

setAttrOrProp: function(el, attrName, val){
attrName = attrName.toLowerCase();
setAttrOrProp: function(el, caseSensitiveAttrName, val){
var attrName = caseSensitiveAttrName.toLowerCase();
var special = specialAttributes[attrName];
if(special && special.isBoolean && !val) {
this.remove(el, attrName);
} else if (!special && caseSensitiveAttrName in el) {
el[caseSensitiveAttrName] = val;
} else {

@@ -458,5 +460,8 @@ this.set(el, attrName, val);

// ## attr.get
// Gets the value of an attribute. First checks if the property is an `specialAttributes` and if so calls the special getter. Otherwise uses `getAttribute` to retrieve the value.
get: function (el, attrName) {
attrName = attrName.toLowerCase();
// Gets the value of an attribute or property.
// First checks if the property is an `specialAttributes` and if so calls the special getter.
// Then checks if the attribute or property is a property on the element.
// Otherwise uses `getAttribute` to retrieve the value.
get: function (el, caseSensitiveAttrName) {
var attrName = caseSensitiveAttrName.toLowerCase();
var special = specialAttributes[attrName];

@@ -468,2 +473,4 @@ var getter = special && special.get;

return getter.call(el);
} else if (caseSensitiveAttrName in el) {
return el[caseSensitiveAttrName];
} else {

@@ -470,0 +477,0 @@ return el.getAttribute(attrName);

@@ -67,5 +67,3 @@ var canReflect = require("can-reflect");

testIfRealDocument("able to read normal attributes", function(assert) {
var div = document.createElement("div");

@@ -81,2 +79,19 @@ div.setAttribute("foo","bar");

});
testIfRealDocument("able to read and write properties when they exist on the element and are not in 'special' list", function(assert) {
var video = document.createElement("video");
video.currentTime = 5.0;
var ta = this.fixture;
ta.appendChild(video);
var obs = new AttributeObservable(video, "currentTime", {});
assert.equal(canReflect.getValue(obs), 5.0, "correct default value");
canReflect.setValue(obs, 10.0);
assert.equal(canReflect.getValue(obs), 10.0, "correct updated value");
assert.equal(video.currentTime, 10.0, "correct updated property");
});
});
{
"name": "can-attribute-observable",
"version": "0.1.0",
"version": "0.2.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