Skip to content

Commit 96a6012

Browse files
committed
fix: allow spaces surrounding url
1 parent b527ed7 commit 96a6012

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
@@ -384,6 +384,12 @@ describe('CSSStyleDeclaration', () => {
384384
expect(style.backgroundImage).toEqual('url(http://some/url/here3.png)');
385385
});
386386

387+
test('url parsing works surrounded by spaces', () => {
388+
var style = new CSSStyleDeclaration();
389+
style.backgroundImage = 'url( http://some/url/here1.png )';
390+
expect(style.backgroundImage).toEqual('url(http://some/url/here1.png)');
391+
});
392+
387393
test('setting 0 to a padding or margin works', () => {
388394
var style = new CSSStyleDeclaration();
389395
style.padding = 0;

lib/parsers.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ exports.parseUrl = function parseUrl(val) {
237237
if (str[0] === '"' || str[0] === "'") {
238238
str = str.substr(1, str.length - 2);
239239
}
240+
str = str.trim();
240241

241242
var i;
242243
for (i = 0; i < str.length; i++) {

0 commit comments

Comments
 (0)