-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
37 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
/*! litejs.com/MIT-LICENSE.txt */ | ||
|
||
exports.CSSStyleDeclaration = CSSStyleDeclaration | ||
|
||
// CSSStyleDeclaration is a single CSS declaration block, | ||
// accessible via HTMLElement.style for inline styles, document.styleSheets[0].cssRules[0].style, and getComputedStyle() | ||
function CSSStyleDeclaration(style) { | ||
this.cssText = style | ||
} | ||
|
||
CSSStyleDeclaration.prototype = { | ||
get cssText() { | ||
return Object.keys(this).map(function(key) { | ||
return (key === "cssFloat" ? "float:" : hyphenCase(key) + ":") + this[key] | ||
}, this).join(";") | ||
}, | ||
set cssText(style) { | ||
for (var m, re = /(?:^|;)\s*([-a-z]+)\s*:((?:("|')(?:\\.|(?!\3)[^\\])*?\3|[^"';])+)(?=;|$)/ig; (m = re.exec(style)); ) { | ||
this[m[1] === "float" ? "cssFloat" : camelCase(m[1])] = m[2].trim() | ||
} | ||
} | ||
} | ||
|
||
function camelCase(str) { | ||
return str.replace(/-([a-z])/g, function(_, a) { return a.toUpperCase() }) | ||
} | ||
|
||
function hyphenCase(str) { | ||
return str.replace(/[A-Z]/g, "-$&").toLowerCase() | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters