From 609084fb3ef7b018c17b2a9e8909539b6d566746 Mon Sep 17 00:00:00 2001 From: Mikhail Korepanov Date: Mon, 1 Apr 2019 19:58:22 +0300 Subject: [PATCH] Pass block to the render of an expression in an attribute --- src/compile/render-dom/wrappers/Element/Attribute.ts | 2 +- .../runtime/samples/contextual-callback-b/_config.js | 12 ++++++++++++ .../samples/contextual-callback-b/main.svelte | 11 +++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 test/runtime/samples/contextual-callback-b/_config.js create mode 100644 test/runtime/samples/contextual-callback-b/main.svelte diff --git a/src/compile/render-dom/wrappers/Element/Attribute.ts b/src/compile/render-dom/wrappers/Element/Attribute.ts index 207e706fa4..680c50e992 100644 --- a/src/compile/render-dom/wrappers/Element/Attribute.ts +++ b/src/compile/render-dom/wrappers/Element/Attribute.ts @@ -78,7 +78,7 @@ export default class AttributeWrapper { // DRY it out if that's possible without introducing crazy indirection if (this.node.chunks.length === 1) { // single {tag} — may be a non-string - value = this.node.chunks[0].render(); + value = this.node.chunks[0].render(block); } else { // '{foo} {bar}' — treat as string concatenation value = diff --git a/test/runtime/samples/contextual-callback-b/_config.js b/test/runtime/samples/contextual-callback-b/_config.js new file mode 100644 index 0000000000..f2ed7f5f59 --- /dev/null +++ b/test/runtime/samples/contextual-callback-b/_config.js @@ -0,0 +1,12 @@ +export default { + html: ` + + ` +}; diff --git a/test/runtime/samples/contextual-callback-b/main.svelte b/test/runtime/samples/contextual-callback-b/main.svelte new file mode 100644 index 0000000000..0010c01fc4 --- /dev/null +++ b/test/runtime/samples/contextual-callback-b/main.svelte @@ -0,0 +1,11 @@ + + +