Skip to content

Commit

Permalink
fix(element-observation): handle extra spacing around css properties
Browse files Browse the repository at this point in the history
This change allows for any amount of whitespace to be included around css
property names. Previously the style would be lost if there were any extra
whitespace around the property name.

Closes #325
  • Loading branch information
32graham committed Feb 28, 2016
1 parent 3076972 commit cb8a907
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/element-observation.js
Expand Up @@ -82,7 +82,7 @@ export class StyleObserver {
let pairs = newValue.split(/(?:;|:(?!\/))\s*/);
for( let i = 0, length = pairs.length; i < length; i++ )
{
style = pairs[i];
style = pairs[i].trim();
if ( !style ) { continue; }

styles[style] = version;
Expand Down
2 changes: 1 addition & 1 deletion test/element-observation.spec.js
Expand Up @@ -155,7 +155,7 @@ describe('element observation', () => {
expect(observer instanceof StyleObserver).toBe(true);
expect(() => observer.subscribe(() => {})).toThrow(new Error('Observation of a "DIV" element\'s "' + attrs[i] + '" property is not supported.'));

observer.setValue('width: 30px; height:20px; background-color: red;background-image: url("http://aurelia.io/test.png");');
observer.setValue(' width : 30px;height:20px; background-color : red;background-image: url("http://aurelia.io/test.png"); ');
expect(observer.getValue()).toBe('width: 30px; height: 20px; background-image: url("http://aurelia.io/test.png"); background-color: red;');
expect(el.style.height).toBe('20px');
expect(el.style.width).toBe('30px');
Expand Down

0 comments on commit cb8a907

Please sign in to comment.