From f10e86f6e2294ddb72edebd6b6d6f4e447eab6c0 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Mon, 27 Nov 2017 08:12:11 -0500 Subject: [PATCH] prevent boolean attributes breaking shapes inside estree-walker - fixes #961 --- src/generators/Generator.ts | 11 ++--------- .../Link.html | 1 + .../_config.js | 3 +++ .../main.html | 10 ++++++++++ 4 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 test/runtime/samples/component-data-static-boolean-regression/Link.html create mode 100644 test/runtime/samples/component-data-static-boolean-regression/_config.js create mode 100644 test/runtime/samples/component-data-static-boolean-regression/main.html diff --git a/src/generators/Generator.ts b/src/generators/Generator.ts index 44b93f85c5..3cd6d5da25 100644 --- a/src/generators/Generator.ts +++ b/src/generators/Generator.ts @@ -72,15 +72,8 @@ function removeIndentation( // We need to tell estree-walker that it should always // look for an `else` block, otherwise it might get // the wrong idea about the shape of each/if blocks -childKeys.EachBlock = [ - 'children', - 'else' -]; - -childKeys.IfBlock = [ - 'children', - 'else' -]; +childKeys.EachBlock = childKeys.IfBlock = ['children', 'else']; +childKeys.Attribute = ['value']; export default class Generator { ast: Parsed; diff --git a/test/runtime/samples/component-data-static-boolean-regression/Link.html b/test/runtime/samples/component-data-static-boolean-regression/Link.html new file mode 100644 index 0000000000..ecdf709900 --- /dev/null +++ b/test/runtime/samples/component-data-static-boolean-regression/Link.html @@ -0,0 +1 @@ +link \ No newline at end of file diff --git a/test/runtime/samples/component-data-static-boolean-regression/_config.js b/test/runtime/samples/component-data-static-boolean-regression/_config.js new file mode 100644 index 0000000000..61f8ba0a06 --- /dev/null +++ b/test/runtime/samples/component-data-static-boolean-regression/_config.js @@ -0,0 +1,3 @@ +export default { + html: `link` +}; diff --git a/test/runtime/samples/component-data-static-boolean-regression/main.html b/test/runtime/samples/component-data-static-boolean-regression/main.html new file mode 100644 index 0000000000..5f51d903b3 --- /dev/null +++ b/test/runtime/samples/component-data-static-boolean-regression/main.html @@ -0,0 +1,10 @@ + + + \ No newline at end of file