From 97184b789caa8885e8f6233ca7c538135c4193db Mon Sep 17 00:00:00 2001 From: Emil Tholin Date: Tue, 14 May 2019 11:32:37 +0200 Subject: [PATCH] Set quote_mark to null when closing quote mark is found --- src/compile/render-dom/wrappers/Element/StyleAttribute.ts | 4 ++-- test/runtime/samples/attribute-url/_config.js | 8 ++++++++ test/runtime/samples/attribute-url/main.svelte | 6 ++++++ 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 test/runtime/samples/attribute-url/_config.js create mode 100644 test/runtime/samples/attribute-url/main.svelte diff --git a/src/compile/render-dom/wrappers/Element/StyleAttribute.ts b/src/compile/render-dom/wrappers/Element/StyleAttribute.ts index b0a3663c63..43524ff372 100644 --- a/src/compile/render-dom/wrappers/Element/StyleAttribute.ts +++ b/src/compile/render-dom/wrappers/Element/StyleAttribute.ts @@ -122,7 +122,7 @@ function get_style_value(chunks: Node[]) { } else if (char === '\\') { escaped = true; } else if (char === quote_mark) { - quote_mark === null; + quote_mark = null; } else if (char === '"' || char === "'") { quote_mark = char; } else if (char === ')' && in_url) { @@ -173,4 +173,4 @@ function get_style_value(chunks: Node[]) { function is_dynamic(value: Node[]) { return value.length > 1 || value[0].type !== 'Text'; -} \ No newline at end of file +} diff --git a/test/runtime/samples/attribute-url/_config.js b/test/runtime/samples/attribute-url/_config.js new file mode 100644 index 0000000000..28bc1bcb0c --- /dev/null +++ b/test/runtime/samples/attribute-url/_config.js @@ -0,0 +1,8 @@ +export default { + test({ assert, target }) { + const div = target.querySelector( 'div' ); + + assert.equal( div.style.backgroundImage, 'url(https://example.com/foo.jpg)'); + assert.equal( div.style.color, 'red' ); + } +}; diff --git a/test/runtime/samples/attribute-url/main.svelte b/test/runtime/samples/attribute-url/main.svelte new file mode 100644 index 0000000000..357a352aaa --- /dev/null +++ b/test/runtime/samples/attribute-url/main.svelte @@ -0,0 +1,6 @@ + + +
{color}