Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don’t worry, you can still create the pull request.
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Commits on Sep 07, 2011
@fgnass fgnass The cssText property now also includes properties that have been set …
…directly rather than via the setProperty() method.
52a343c
Commits on Dec 21, 2011
@fgnass fgnass Merge branch 'gh-pages' of https://github.com/NV/CSSOM into cssText
* 'gh-pages' of https://github.com/NV/CSSOM:
  Version bump
  Add test for CSSStyleDeclaration#cssText. Speed up a bit. Closes #29. @papandreou, thanks!
  Implemented CSSStyleDeclaration.cssText setter (hackingly). Closes #29.
  Fix: npm WARN cssom@0.2.0 package.json: bugs['web'] should probably be bugs['url']
  Fix demo page. JSON.stringify caused an error since I added circular references (i.e. parentRule). Replace JSON.stringify with custom made object stringifier.

Conflicts:
	lib/CSSStyleDeclaration.js
f1e0a62
Showing with 15 additions and 8 deletions.
  1. +12 −8 lib/CSSStyleDeclaration.js
  2. +3 −0  test/CSSStyleDeclaration.test.js
View
20 lib/CSSStyleDeclaration.js
@@ -71,6 +71,7 @@ CSSOM.CSSStyleDeclaration.prototype = {
}
var prevValue = this[name];
this[name] = "";
+ this._importants[name] = "";
// That's what WebKit and Opera do
Array.prototype.splice.call(this, index, 1);
@@ -108,16 +109,19 @@ CSSOM.CSSStyleDeclaration.prototype = {
},
// Doesn't work in IE < 9
- get cssText(){
+ get cssText() {
var properties = [];
- for (var i=0, length=this.length; i < length; ++i) {
- var name = this[i];
- var value = this.getPropertyValue(name);
- var priority = this.getPropertyPriority(name);
- if (priority) {
- priority = " !" + priority;
+ for (var name in this) {
+ if (this.hasOwnProperty(name) && !name.match(/^_.*|\d+$|length/)) {
+ var value = this.getPropertyValue(name);
+ if (value !== "") {
+ var priority = this.getPropertyPriority(name);
+ if (priority) {
+ priority = " !" + priority;
+ }
+ properties.push(name + ': ' + value + priority + ';');
+ }
}
- properties[i] = name + ": " + value + priority + ";";
}
return properties.join(" ")
},
View
3  test/CSSStyleDeclaration.test.js
@@ -32,6 +32,9 @@ test("CSSStyleDeclaration", function(){
equal(d.cssText, "color: green;");
+ d.color = "papayawhip";
+ d.width = "100%";
+ equal(d.cssText, "color: papayawhip; width: 100%;");
});
test("CSSStyleDeclaration#cssText", function(){

No commit comments for this range

Something went wrong with that request. Please try again.