Skip to content

Commit 0e42fb2

Browse files
committed
fix: allow spaces surrounding url
1 parent 7284d37 commit 0e42fb2

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lib/CSSStyleDeclaration.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,12 @@ describe('CSSStyleDeclaration', () => {
437437
expect(style.backgroundImage).toEqual('url(http://some/url/here3.png)');
438438
});
439439

440+
test('url parsing works surrounded by spaces', () => {
441+
var style = new CSSStyleDeclaration();
442+
style.backgroundImage = 'url( http://some/url/here1.png )';
443+
expect(style.backgroundImage).toEqual('url(http://some/url/here1.png)');
444+
});
445+
440446
test('setting 0 to a padding or margin works', () => {
441447
var style = new CSSStyleDeclaration();
442448
style.padding = 0;

lib/parsers.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ exports.parseUrl = function parseUrl(val) {
243243
if (str[0] === '"' || str[0] === "'") {
244244
str = str.substr(1, str.length - 2);
245245
}
246+
str = str.trim();
246247

247248
var i;
248249
for (i = 0; i < str.length; i++) {

0 commit comments

Comments
 (0)