Permalink
Browse files

Cross-browser! Object.defineProperty is not used any more.

  • Loading branch information...
NV committed Dec 11, 2010
1 parent b621f5d commit 83a33a60ffb9fa9edc75ba5f8b903d931bd125ce
Showing with 13 additions and 16 deletions.
  1. +1 −2 README.mdown
  2. +3 −6 lib/CSSStyleDeclaration.js
  3. +1 −1 lib/clone.js
  4. +8 −7 test/helper.js
View
@@ -22,8 +22,7 @@ CSSOM.js is a CSS parser written in pure JavaScript. It also a partial implement
## [Tests](http://nv.github.com/CSSOM/test/)
CSSOM.js uses ECMAScript 5 features such as `Object.defineProperty`. It currently works in Google Chrome 6+, Safari 5, Firefox 4 beta and IE9 beta. Opera (including 11 alpha) does not support `Object.defineProperty`.
Works well in Google Chrome 6+, Safari 5+, Firefox 3.6+, Opera 10.63 and IE8+.
## Build
@@ -11,10 +11,7 @@ CSSOM.CSSStyleDeclaration = function CSSStyleDeclaration(){
this.length = 0;
// NON-STANDARD
Object.defineProperty(this, "importants", {
value: {},
enumerable: false
});
this._importants = {};
};
@@ -54,7 +51,7 @@ CSSOM.CSSStyleDeclaration.prototype = {
this.length++;
}
this[name] = value;
this.importants[name] = !!priority;
this._importants[name] = !!priority;
},
/**
@@ -93,7 +90,7 @@ CSSOM.CSSStyleDeclaration.prototype = {
* @param {String} name
*/
getPropertyPriority: function(name) {
return this.importants[name] ? "important" : "";
return this._importants[name] ? "important" : "";
},
View
@@ -42,7 +42,7 @@ CSSOM.clone = function clone(stylesheet) {
for (var j=0, styleLength=style.length; j < styleLength; j++) {
var name = styleClone[j] = style[j];
styleClone[name] = style[name];
styleClone.importants[name] = style.getPropertyPriority(name);
styleClone._importants[name] = style.getPropertyPriority(name);
}
styleClone.length = style.length;
}
View
@@ -19,12 +19,13 @@ function equalOwnProperties(actual, expected, message) {
function cloneOwnProperties(object) {
var result = {};
for (var key in object) {
if (object.hasOwnProperty(key)) {
if (typeof object[key] == "object") {
result[key] = cloneOwnProperties(object[key]);
} else {
result[key] = object[key];
}
if (key.charAt(0) == "_" || !object.hasOwnProperty(key)) {
continue;
}
if (typeof object[key] == "object") {
result[key] = cloneOwnProperties(object[key]);
} else {
result[key] = object[key];
}
}
return result;
@@ -59,7 +60,7 @@ function subsetOfOwnProperties(base, another) {
var diff = {};
var isDiff = false;
for (var key in another) {
if (!another.hasOwnProperty(key)) {
if (key.charAt(0) == "_" || !another.hasOwnProperty(key)) {
continue;
}
if (key in base) {

0 comments on commit 83a33a6

Please sign in to comment.