Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Update prefixfree.dynamic-dom.js #176

Open
wants to merge 3 commits into
base: gh-pages
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 46 additions & 38 deletions plugins/prefixfree.dynamic-dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,46 +51,54 @@ if(!self) {
}

// Add accessors for CSSOM property changes
if(window.CSSStyleDeclaration) {
for(var i=0; i<self.properties.length; i++) {
var property = StyleFix.camelCase(self.properties[i]),
prefixed = self.prefixProperty(property, true),
proto = CSSStyleDeclaration.prototype,
getter,
setter;

// Lowercase prefix for IE
if(!(prefixed in proto)) {
prefixed = prefixed.charAt(0).toLowerCase() + prefixed.slice(1);
if(!(prefixed in proto)) {
continue;
}
}

getter = (function(prefixed) {
return function() {
return this[prefixed];
}
})(prefixed);
setter = (function(prefixed) {
return function(value) {
this[prefixed] = value;
}
})(prefixed);

if(Object.defineProperty) {
Object.defineProperty(proto, property, {
get: getter,
set: setter,
enumerable: true,
configurable: true
});
var style = document.documentElement.style,
proto = style.constructor.prototype;

while (style !== Object.prototype && !style.hasOwnProperty("color")){
style = style.constructor.prototype;
}

var properties = Object.getOwnPropertyNames(style),
prefixRE = new RegExp("^["+self.Prefix.charAt(0).toLowerCase()+self.Prefix.replace(/(^.)/,"$1]")+"([A-Z])(.*)");

var i=0,
property="",
unprefixed="",
match;

var getter = function(property){
return function(){
return this[property];
}
else if(proto.__defineGetter__) {
proto.__defineGetter__(property, getter);
proto.__defineSetter__(property, setter);
}

var setter = function(property){
return function(value){
this[property] = value;
}
}
}

})(window.PrefixFree);
while (i < properties.length){
property = properties[i++];
match = property.match(prefixRE);

if (!match || style.hasOwnProperty(unprefixed = match[1].toLowerCase() + match[2])){
continue;
}


if (Object.defineProperty) {
Object.defineProperty(proto, unprefixed, {
get: getter(property),
set: setter(property),
enumerable: true,
configurable: true
});
} else if(proto.__defineGetter__) {
proto.__defineGetter__(unprefixed, getter(property));
proto.__defineSetter__(unprefixed, setter(property));
}
};

})(window.PrefixFree);