From 47128c63836e842ca2aceef8dbb5f0103f07cb2c Mon Sep 17 00:00:00 2001 From: Andrew Patton Date: Thu, 12 May 2016 01:50:03 -0700 Subject: [PATCH 1/2] Add tests for setProperty with opacity: 0 --- spec/CSSStyleDeclaration.spec.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spec/CSSStyleDeclaration.spec.js b/spec/CSSStyleDeclaration.spec.js index 0d092b1..39ccac7 100644 --- a/spec/CSSStyleDeclaration.spec.js +++ b/spec/CSSStyleDeclaration.spec.js @@ -29,10 +29,13 @@ describe('CSSStyleDeclaration', function() { } }); - expect(d.cssText).toBe('color: purple; width: 128px !important;'); + d.setProperty('opacity', 0); + + expect(d.cssText).toBe('color: purple; width: 128px !important; opacity: 0;'); expect(d.getPropertyValue('color')).toBe('purple'); expect(d.getPropertyValue('width')).toBe('128px'); + expect(d.getPropertyValue('opacity')).toBe('0'); expect(d.getPropertyValue('position')).toBe(''); expect(d.getPropertyPriority('color')).toBe(''); @@ -41,6 +44,7 @@ describe('CSSStyleDeclaration', function() { d.setProperty('color', 'green'); d.removeProperty('width'); + d.removeProperty('opacity'); expect(d.cssText).toBe('color: green;'); }); From 7b798067932db92554a271300f6b39bf927b7803 Mon Sep 17 00:00:00 2001 From: Andrew Patton Date: Thu, 12 May 2016 01:52:52 -0700 Subject: [PATCH 2/2] Coerce setProperty's value to string, fix #81 --- lib/CSSStyleDeclaration.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/CSSStyleDeclaration.js b/lib/CSSStyleDeclaration.js index 55e024c..b43b9af 100644 --- a/lib/CSSStyleDeclaration.js +++ b/lib/CSSStyleDeclaration.js @@ -51,7 +51,7 @@ CSSOM.CSSStyleDeclaration.prototype = { this[this.length] = name; this.length++; } - this[name] = value; + this[name] = value + ""; this._importants[name] = priority; },