From 9550741ee6a5ae9ff694828efcbaa3a776422816 Mon Sep 17 00:00:00 2001 From: Dylan Piercey Date: Fri, 24 Apr 2020 16:32:26 -0700 Subject: [PATCH] fix: regression with unquoted attribute with trailing slash --- .../marko/src/runtime/components/beginComponent.js | 6 +++--- .../marko/src/runtime/components/endComponent.js | 2 +- packages/marko/src/runtime/html/AsyncStream.js | 4 ++-- packages/marko/src/runtime/html/helpers/attr.js | 2 +- .../component-to-template/initial-expected.html | 2 +- .../initial-expected.html | 2 +- .../reloaded-expected.html | 2 +- .../template-to-component/reloaded-expected.html | 2 +- .../components-await-beginAsync/expected.html | 2 +- .../components-await-title/expected.html | 2 +- .../components-await/expected.html | 2 +- .../component-aria-key/expected.html | 2 +- .../component-elId/expected.html | 2 +- .../component-getElId/expected.html | 2 +- .../render/fixtures/attr-unquoted/expected.html | 2 ++ .../render/fixtures/attr-unquoted/template.marko | 14 ++++++++++++++ .../test/render/fixtures/attr-unquoted/test.js | 1 + .../fixtures/attr-unquoted/vdom-expected.html | 2 ++ .../fixtures/component-aria-key/expected.html | 2 +- .../component-file-export-class/expected.html | 2 +- .../fixtures/component-label-for/expected.html | 2 +- .../fixtures/component-safe-json/expected.html | 2 +- .../components-await-beginAsync/expected.html | 2 +- .../fixtures/components-await-title/expected.html | 2 +- .../render/fixtures/components-await/expected.html | 2 +- .../test/render/fixtures/components/expected.html | 2 +- .../fixtures/dynamic-split-component/expected.html | 2 +- .../fixtures/dynamic-tag-arguments/expected.html | 2 +- .../fixtures/global-runtime-id/expected.html | 2 +- 29 files changed, 47 insertions(+), 28 deletions(-) create mode 100644 packages/marko/test/render/fixtures/attr-unquoted/expected.html create mode 100644 packages/marko/test/render/fixtures/attr-unquoted/template.marko create mode 100644 packages/marko/test/render/fixtures/attr-unquoted/test.js create mode 100644 packages/marko/test/render/fixtures/attr-unquoted/vdom-expected.html diff --git a/packages/marko/src/runtime/components/beginComponent.js b/packages/marko/src/runtime/components/beginComponent.js index d87079c4ef..2840305cb1 100644 --- a/packages/marko/src/runtime/components/beginComponent.js +++ b/packages/marko/src/runtime/components/beginComponent.js @@ -65,7 +65,7 @@ module.exports = function beginComponent( if ((ownerIsRenderBoundary || ownerWillRerender) && key != null) { out.w( - "" + "-->" ); } else { - out.w(""); + out.w(""); } return componentDef; diff --git a/packages/marko/src/runtime/components/endComponent.js b/packages/marko/src/runtime/components/endComponent.js index 56025bd6ac..8296cc1e9b 100644 --- a/packages/marko/src/runtime/components/endComponent.js +++ b/packages/marko/src/runtime/components/endComponent.js @@ -5,7 +5,7 @@ var getComponentsContext = ComponentsContext.___getComponentsContext; module.exports = function endComponent(out, componentDef) { if (componentDef.___renderBoundary) { - out.w(""); + out.w(""); getComponentsContext(out).___isPreserved = componentDef.___parentPreserved; } }; diff --git a/packages/marko/src/runtime/html/AsyncStream.js b/packages/marko/src/runtime/html/AsyncStream.js index 5d8d0b726f..2fb9260308 100644 --- a/packages/marko/src/runtime/html/AsyncStream.js +++ b/packages/marko/src/runtime/html/AsyncStream.js @@ -573,7 +573,7 @@ var proto = (AsyncStream.prototype = { ___beginFragment: function(key, component, preserve) { if (preserve) { - this.write(""); + this.write(""); } if (this._elStack) { this._elStack.push(preserve); @@ -585,7 +585,7 @@ var proto = (AsyncStream.prototype = { ___endFragment: function() { var preserve = this._elStack.pop(); if (preserve) { - this.write(""); + this.write(""); } }, diff --git a/packages/marko/src/runtime/html/helpers/attr.js b/packages/marko/src/runtime/html/helpers/attr.js index b2a87c9a9b..f6f828cc31 100644 --- a/packages/marko/src/runtime/html/helpers/attr.js +++ b/packages/marko/src/runtime/html/helpers/attr.js @@ -75,5 +75,5 @@ function guessQuotes(value) { } } - return value && "=" + value; + return value && "=" + (value[len - 1] === "/" ? value + " " : value); } diff --git a/packages/marko/test/hot-reload/fixtures/component-to-template/initial-expected.html b/packages/marko/test/hot-reload/fixtures/component-to-template/initial-expected.html index 47c5fc19ae..b1e5367cdf 100644 --- a/packages/marko/test/hot-reload/fixtures/component-to-template/initial-expected.html +++ b/packages/marko/test/hot-reload/fixtures/component-to-template/initial-expected.html @@ -1 +1 @@ -
Hello Frank
\ No newline at end of file +
Hello Frank
\ No newline at end of file diff --git a/packages/marko/test/hot-reload/fixtures/template-export-component/initial-expected.html b/packages/marko/test/hot-reload/fixtures/template-export-component/initial-expected.html index 47c5fc19ae..b1e5367cdf 100644 --- a/packages/marko/test/hot-reload/fixtures/template-export-component/initial-expected.html +++ b/packages/marko/test/hot-reload/fixtures/template-export-component/initial-expected.html @@ -1 +1 @@ -
Hello Frank
\ No newline at end of file +
Hello Frank
\ No newline at end of file diff --git a/packages/marko/test/hot-reload/fixtures/template-export-component/reloaded-expected.html b/packages/marko/test/hot-reload/fixtures/template-export-component/reloaded-expected.html index 705ba3996b..b3c79025bc 100644 --- a/packages/marko/test/hot-reload/fixtures/template-export-component/reloaded-expected.html +++ b/packages/marko/test/hot-reload/fixtures/template-export-component/reloaded-expected.html @@ -1 +1 @@ -
Hello Frank
\ No newline at end of file +
Hello Frank
\ No newline at end of file diff --git a/packages/marko/test/hot-reload/fixtures/template-to-component/reloaded-expected.html b/packages/marko/test/hot-reload/fixtures/template-to-component/reloaded-expected.html index 87132d7ad3..3e8f2ad118 100644 --- a/packages/marko/test/hot-reload/fixtures/template-to-component/reloaded-expected.html +++ b/packages/marko/test/hot-reload/fixtures/template-to-component/reloaded-expected.html @@ -1 +1 @@ -
Hello Jane
\ No newline at end of file +
Hello Jane
\ No newline at end of file diff --git a/packages/marko/test/render/fixtures-async-deprecated/components-await-beginAsync/expected.html b/packages/marko/test/render/fixtures-async-deprecated/components-await-beginAsync/expected.html index e0ea0917e5..d88031149f 100644 --- a/packages/marko/test/render/fixtures-async-deprecated/components-await-beginAsync/expected.html +++ b/packages/marko/test/render/fixtures-async-deprecated/components-await-beginAsync/expected.html @@ -1 +1 @@ -
Hello inner-inner
Hello inner
Hello outer
\ No newline at end of file +
Hello inner-inner
Hello inner
Hello outer
\ No newline at end of file diff --git a/packages/marko/test/render/fixtures-async-deprecated/components-await-title/expected.html b/packages/marko/test/render/fixtures-async-deprecated/components-await-title/expected.html index 3e0e6dd290..f812d1f2d3 100644 --- a/packages/marko/test/render/fixtures-async-deprecated/components-await-title/expected.html +++ b/packages/marko/test/render/fixtures-async-deprecated/components-await-title/expected.html @@ -1 +1 @@ -<!--FLUSH-->Welcome Frank
Hello
\ No newline at end of file +<!--FLUSH-->Welcome Frank
Hello
\ No newline at end of file diff --git a/packages/marko/test/render/fixtures-async-deprecated/components-await/expected.html b/packages/marko/test/render/fixtures-async-deprecated/components-await/expected.html index 4f19881ea5..c45ac3972c 100644 --- a/packages/marko/test/render/fixtures-async-deprecated/components-await/expected.html +++ b/packages/marko/test/render/fixtures-async-deprecated/components-await/expected.html @@ -1 +1 @@ -
Hello inner-inner
Hello inner
Hello outer
\ No newline at end of file +
Hello inner-inner
Hello inner
Hello outer
\ No newline at end of file diff --git a/packages/marko/test/render/fixtures-deprecated/component-aria-key/expected.html b/packages/marko/test/render/fixtures-deprecated/component-aria-key/expected.html index ee0c4bb507..2ab2e0a79e 100644 --- a/packages/marko/test/render/fixtures-deprecated/component-aria-key/expected.html +++ b/packages/marko/test/render/fixtures-deprecated/component-aria-key/expected.html @@ -1 +1 @@ -
Submit the form thing
\ No newline at end of file +
Submit the form thing
\ No newline at end of file diff --git a/packages/marko/test/render/fixtures-deprecated/component-elId/expected.html b/packages/marko/test/render/fixtures-deprecated/component-elId/expected.html index abb68c52a0..b669e61bde 100644 --- a/packages/marko/test/render/fixtures-deprecated/component-elId/expected.html +++ b/packages/marko/test/render/fixtures-deprecated/component-elId/expected.html @@ -1 +1 @@ -
\ No newline at end of file +
\ No newline at end of file diff --git a/packages/marko/test/render/fixtures-deprecated/component-getElId/expected.html b/packages/marko/test/render/fixtures-deprecated/component-getElId/expected.html index abb68c52a0..b669e61bde 100644 --- a/packages/marko/test/render/fixtures-deprecated/component-getElId/expected.html +++ b/packages/marko/test/render/fixtures-deprecated/component-getElId/expected.html @@ -1 +1 @@ -
\ No newline at end of file +
\ No newline at end of file diff --git a/packages/marko/test/render/fixtures/attr-unquoted/expected.html b/packages/marko/test/render/fixtures/attr-unquoted/expected.html new file mode 100644 index 0000000000..e9f48cf7e3 --- /dev/null +++ b/packages/marko/test/render/fixtures/attr-unquoted/expected.html @@ -0,0 +1,2 @@ +
\ No newline at end of file diff --git a/packages/marko/test/render/fixtures/attr-unquoted/template.marko b/packages/marko/test/render/fixtures/attr-unquoted/template.marko new file mode 100644 index 0000000000..460fcf2450 --- /dev/null +++ b/packages/marko/test/render/fixtures/attr-unquoted/template.marko @@ -0,0 +1,14 @@ +
\ No newline at end of file diff --git a/packages/marko/test/render/fixtures/attr-unquoted/test.js b/packages/marko/test/render/fixtures/attr-unquoted/test.js new file mode 100644 index 0000000000..c4013b3447 --- /dev/null +++ b/packages/marko/test/render/fixtures/attr-unquoted/test.js @@ -0,0 +1 @@ +exports.templateData = {}; diff --git a/packages/marko/test/render/fixtures/attr-unquoted/vdom-expected.html b/packages/marko/test/render/fixtures/attr-unquoted/vdom-expected.html new file mode 100644 index 0000000000..98c918726d --- /dev/null +++ b/packages/marko/test/render/fixtures/attr-unquoted/vdom-expected.html @@ -0,0 +1,2 @@ +
diff --git a/packages/marko/test/render/fixtures/component-aria-key/expected.html b/packages/marko/test/render/fixtures/component-aria-key/expected.html index ee0c4bb507..2ab2e0a79e 100644 --- a/packages/marko/test/render/fixtures/component-aria-key/expected.html +++ b/packages/marko/test/render/fixtures/component-aria-key/expected.html @@ -1 +1 @@ -
Submit the form thing
\ No newline at end of file +
Submit the form thing
\ No newline at end of file diff --git a/packages/marko/test/render/fixtures/component-file-export-class/expected.html b/packages/marko/test/render/fixtures/component-file-export-class/expected.html index 4860619b97..22d361194f 100644 --- a/packages/marko/test/render/fixtures/component-file-export-class/expected.html +++ b/packages/marko/test/render/fixtures/component-file-export-class/expected.html @@ -1 +1 @@ -
Hello Frank!
\ No newline at end of file +
Hello Frank!
\ No newline at end of file diff --git a/packages/marko/test/render/fixtures/component-label-for/expected.html b/packages/marko/test/render/fixtures/component-label-for/expected.html index 6e10fc96aa..e5ad8636a6 100644 --- a/packages/marko/test/render/fixtures/component-label-for/expected.html +++ b/packages/marko/test/render/fixtures/component-label-for/expected.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/packages/marko/test/render/fixtures/component-safe-json/expected.html b/packages/marko/test/render/fixtures/component-safe-json/expected.html index 32db92cb34..c115077b30 100644 --- a/packages/marko/test/render/fixtures/component-safe-json/expected.html +++ b/packages/marko/test/render/fixtures/component-safe-json/expected.html @@ -1 +1 @@ -Hello \ No newline at end of file +Hello \ No newline at end of file diff --git a/packages/marko/test/render/fixtures/components-await-beginAsync/expected.html b/packages/marko/test/render/fixtures/components-await-beginAsync/expected.html index 18ccc5de9d..cf4ffaa0f1 100644 --- a/packages/marko/test/render/fixtures/components-await-beginAsync/expected.html +++ b/packages/marko/test/render/fixtures/components-await-beginAsync/expected.html @@ -1 +1 @@ -
Hello inner-inner
Hello inner
Hello outer
\ No newline at end of file +
Hello inner-inner
Hello inner
Hello outer
\ No newline at end of file diff --git a/packages/marko/test/render/fixtures/components-await-title/expected.html b/packages/marko/test/render/fixtures/components-await-title/expected.html index 626cf8432a..93c7ffcd04 100644 --- a/packages/marko/test/render/fixtures/components-await-title/expected.html +++ b/packages/marko/test/render/fixtures/components-await-title/expected.html @@ -1 +1 @@ -<!--FLUSH-->Welcome Frank
Hello
\ No newline at end of file +<!--FLUSH-->Welcome Frank
Hello
\ No newline at end of file diff --git a/packages/marko/test/render/fixtures/components-await/expected.html b/packages/marko/test/render/fixtures/components-await/expected.html index 9021adf5a7..f29085e296 100644 --- a/packages/marko/test/render/fixtures/components-await/expected.html +++ b/packages/marko/test/render/fixtures/components-await/expected.html @@ -1 +1 @@ -
Hello inner-inner
Hello inner
Hello outer
\ No newline at end of file +
Hello inner-inner
Hello inner
Hello outer
\ No newline at end of file diff --git a/packages/marko/test/render/fixtures/components/expected.html b/packages/marko/test/render/fixtures/components/expected.html index e8bd7a40ec..687177b6d1 100644 --- a/packages/marko/test/render/fixtures/components/expected.html +++ b/packages/marko/test/render/fixtures/components/expected.html @@ -1 +1 @@ -Components

foo1

bar1

bar2

foo-split1

split-child1

split-child2

foo-split2

split-child1

split-child2

foo2

bar1

bar2

foo-split1

split-child1

split-child2

foo-split2

split-child1

split-child2

split1

split-child1

split-child2

split2

split-child1

split-child2

\ No newline at end of file +Components

foo1

bar1

bar2

foo-split1

split-child1

split-child2

foo-split2

split-child1

split-child2

foo2

bar1

bar2

foo-split1

split-child1

split-child2

foo-split2

split-child1

split-child2

split1

split-child1

split-child2

split2

split-child1

split-child2

\ No newline at end of file diff --git a/packages/marko/test/render/fixtures/dynamic-split-component/expected.html b/packages/marko/test/render/fixtures/dynamic-split-component/expected.html index 0d6f5401ac..4f0d4972be 100644 --- a/packages/marko/test/render/fixtures/dynamic-split-component/expected.html +++ b/packages/marko/test/render/fixtures/dynamic-split-component/expected.html @@ -1 +1 @@ -
Body data
Body data
\ No newline at end of file +
Body data
Body data
\ No newline at end of file diff --git a/packages/marko/test/render/fixtures/dynamic-tag-arguments/expected.html b/packages/marko/test/render/fixtures/dynamic-tag-arguments/expected.html index b15e3c9e71..5cf81ce4b4 100644 --- a/packages/marko/test/render/fixtures/dynamic-tag-arguments/expected.html +++ b/packages/marko/test/render/fixtures/dynamic-tag-arguments/expected.html @@ -1 +1 @@ -testPage http://ebay.com
\ No newline at end of file +testPage http://ebay.com
\ No newline at end of file diff --git a/packages/marko/test/render/fixtures/global-runtime-id/expected.html b/packages/marko/test/render/fixtures/global-runtime-id/expected.html index 895936a288..7e37ecba4f 100644 --- a/packages/marko/test/render/fixtures/global-runtime-id/expected.html +++ b/packages/marko/test/render/fixtures/global-runtime-id/expected.html @@ -1 +1 @@ -
\ No newline at end of file +
\ No newline at end of file