Skip to content

Commit 184fcbe

Browse files
author
sammizheng
committed
fix: check the priority value of the existing property
1 parent c92a277 commit 184fcbe

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

lib/CSSStyleDeclaration.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,24 @@ CSSOM.CSSStyleDeclaration.prototype = {
4646
this[this.length] = name;
4747
this.length++;
4848
}
49+
50+
// If the priority value of the incoming property is "important",
51+
// or the value of the existing property is not "important",
52+
// then remove the existing property and rewrite it.
53+
if (priority || !this._importants[name]) {
54+
this.removeProperty(name);
55+
this[this.length] = name;
56+
this.length++;
57+
this[name] = value + '';
58+
this._importants[name] = priority;
59+
}
4960
} else {
5061
// New property.
5162
this[this.length] = name;
5263
this.length++;
64+
this[name] = value + '';
65+
this._importants[name] = priority;
5366
}
54-
this[name] = value + "";
55-
this._importants[name] = priority;
5667
},
5768

5869
/**

0 commit comments

Comments
 (0)