Skip to content
This repository has been archived by the owner on Jul 30, 2022. It is now read-only.

Commit

Permalink
Add priority support to CSSStyleDeclaration
Browse files Browse the repository at this point in the history
  • Loading branch information
Manuel Valls Fernández committed Nov 9, 2016
1 parent dd7a710 commit 1ffc721
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
14 changes: 12 additions & 2 deletions apply.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,19 @@ function recursiveSetData(obj,keys,value){
}

function setData(obj,key,value){
if(global.CSSStyleDeclaration && obj instanceof global.CSSStyleDeclaration) [key,value] = getPair(key,value);
if(obj[key] !== value){
var priority = '';

if(global.CSSStyleDeclaration && obj instanceof global.CSSStyleDeclaration){

if(value && value instanceof Array) [value,priority] = value;
[key,value] = getPair(key,value);
obj.setProperty(key,value,priority);

}else if(obj[key] !== value){

obj[key] = value;
getGetter.check(this.base);

}

}
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"version": "7.0.2",
"description": "Useful prototype extensions",
"dependencies": {
"greens": "^1.0.0",
"y-setter": "^6.11.0",
"greens": "^1.0.1",
"y-setter": "^6.12.4",
"y-timers": "^1.1.5"
},
"devDependencies": {
"detacher": "^2.0.4",
"u-test": "^3.7.5"
"detacher": "^2.0.5",
"u-test": "^3.8.9"
},
"scripts": {
"test": "u-test"
Expand Down
3 changes: 2 additions & 1 deletion test/apply.br.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,9 @@ t('apply',function(){
div[apply]({style: {color: null}});
assert.strictEqual(div.style.color,'');

div[apply]({style: {color: 'black'}});
div[apply]({style: {color: ['black','important']}});
assert.strictEqual(div.style.color,'black');
assert.strictEqual(div.style.getPropertyPriority('color'),'important');
});

});

0 comments on commit 1ffc721

Please sign in to comment.