From 3cb8de1c3ce0284bcd95fe09b2052f5e2d25fdba Mon Sep 17 00:00:00 2001 From: Will Harney Date: Wed, 27 Nov 2024 15:20:29 -0500 Subject: [PATCH 01/13] test(ssr): long string of empty text nodes --- .../adjacent-text-nodes/emptier/error.txt | 0 .../adjacent-text-nodes/emptier/expected.html | 7 +++++++ .../adjacent-text-nodes/emptier/index.js | 3 +++ .../modules/x/comments-text/comments-text.html | 3 +++ .../modules/x/comments-text/comments-text.js | 7 +++++++ .../ssr-compiler/src/__tests__/fixtures.spec.ts | 2 +- .../src/__tests__/utils/expected-failures.ts | 2 +- packages/@lwc/ssr-runtime/src/index.ts | 1 + .../@lwc/ssr-runtime/src/isolate-text-nodes.ts | 17 +++++++++++++++++ 9 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/emptier/error.txt create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/emptier/expected.html create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/emptier/index.js create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/emptier/modules/x/comments-text/comments-text.html create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/emptier/modules/x/comments-text/comments-text.js create mode 100644 packages/@lwc/ssr-runtime/src/isolate-text-nodes.ts diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/emptier/error.txt b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/emptier/error.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/emptier/expected.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/emptier/expected.html new file mode 100644 index 0000000000..0e6e634163 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/emptier/expected.html @@ -0,0 +1,7 @@ + + + \ No newline at end of file diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/emptier/index.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/emptier/index.js new file mode 100644 index 0000000000..4bd94488e9 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/emptier/index.js @@ -0,0 +1,3 @@ +export const tagName = 'x-comments-text'; +export { default } from 'x/comments-text'; +export * from 'x/comments-text'; diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/emptier/modules/x/comments-text/comments-text.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/emptier/modules/x/comments-text/comments-text.html new file mode 100644 index 0000000000..023262ffb3 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/emptier/modules/x/comments-text/comments-text.html @@ -0,0 +1,3 @@ + diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/emptier/modules/x/comments-text/comments-text.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/emptier/modules/x/comments-text/comments-text.js new file mode 100644 index 0000000000..44bf0aff54 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/emptier/modules/x/comments-text/comments-text.js @@ -0,0 +1,7 @@ +import { LightningElement } from 'lwc'; + +export default class extends LightningElement { + foo = ''; + bar = undefined; + baz = null; +} diff --git a/packages/@lwc/ssr-compiler/src/__tests__/fixtures.spec.ts b/packages/@lwc/ssr-compiler/src/__tests__/fixtures.spec.ts index c949449ff3..8710f59b0d 100644 --- a/packages/@lwc/ssr-compiler/src/__tests__/fixtures.spec.ts +++ b/packages/@lwc/ssr-compiler/src/__tests__/fixtures.spec.ts @@ -38,7 +38,7 @@ vi.mock('@lwc/ssr-runtime', async () => { return runtime; }); -const SSR_MODE: CompilationMode = DEFAULT_SSR_MODE; +const SSR_MODE: CompilationMode = 'asyncYield'; async function compileFixture({ input, dirname }: { input: string; dirname: string }) { const modulesDir = path.resolve(dirname, './modules'); diff --git a/packages/@lwc/ssr-compiler/src/__tests__/utils/expected-failures.ts b/packages/@lwc/ssr-compiler/src/__tests__/utils/expected-failures.ts index d847cc1f21..50bf613adf 100644 --- a/packages/@lwc/ssr-compiler/src/__tests__/utils/expected-failures.ts +++ b/packages/@lwc/ssr-compiler/src/__tests__/utils/expected-failures.ts @@ -8,7 +8,7 @@ // We should slowly drive down these test failures or at least document where we expect the failures // TODO [#4815]: enable all SSR v2 tests export const expectedFailures = new Set([ - 'adjacent-text-nodes/empty/index.js', + // 'adjacent-text-nodes/empty/index.js', 'adjacent-text-nodes/with-comments/empty1/index.js', 'adjacent-text-nodes/with-comments/empty2/index.js', 'adjacent-text-nodes/with-comments/empty3/index.js', diff --git a/packages/@lwc/ssr-runtime/src/index.ts b/packages/@lwc/ssr-runtime/src/index.ts index bec88d354e..78598b43df 100644 --- a/packages/@lwc/ssr-runtime/src/index.ts +++ b/packages/@lwc/ssr-runtime/src/index.ts @@ -11,6 +11,7 @@ export * from './stubs'; export { htmlEscape, setHooks, sanitizeHtmlContent, normalizeClass } from '@lwc/shared'; export { ClassList } from './class-list'; +export {} from './isolate-text-nodes'; export { LightningElement, LightningElementConstructor, diff --git a/packages/@lwc/ssr-runtime/src/isolate-text-nodes.ts b/packages/@lwc/ssr-runtime/src/isolate-text-nodes.ts new file mode 100644 index 0000000000..286d4f1337 --- /dev/null +++ b/packages/@lwc/ssr-runtime/src/isolate-text-nodes.ts @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2024, Salesforce, Inc. + * All rights reserved. + * SPDX-License-Identifier: MIT + * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT + */ +let buffer = ''; + +export function enqueueTextContent(str: string) { + buffer += str; +} + +export function flushTextContent() { + const result = buffer === '' ? '\u200D' : buffer; + buffer = ''; + return result; +} From 59b273e9f020a1e5f53ec50ce1709a6c09e7855f Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Wed, 27 Nov 2024 13:13:58 -0800 Subject: [PATCH 02/13] fix: more progress on adjacent text nodes --- .../{emptier/error.txt => .only} | 0 .../comments-at-end}/error.txt | 0 .../comments-at-end}/expected.html | 0 .../comments-at-end}/index.js | 0 .../x/comments-text/comments-text.html | 3 ++ .../modules/x/comments-text/comments-text.js | 0 .../comments-then-element}/error.txt | 0 .../comments-then-element/expected.html | 9 +++++ .../comments-then-element}/index.js | 0 .../x/comments-text/comments-text.html | 3 ++ .../modules/x/comments-text/comments-text.js | 0 .../emptier}/error.txt | 0 .../emptier}/expected.html | 0 .../emptier}/index.js | 0 .../x/comments-text/comments-text.html | 0 .../modules/x/comments-text/comments-text.js | 0 .../empty}/error.txt | 0 .../empty}/expected.html | 0 .../empty}/index.js | 0 .../x/comments-text/comments-text.html | 0 .../modules/x/comments-text/comments-text.js | 7 ++++ .../empty1}/error.txt | 0 .../empty1}/expected.html | 0 .../empty1/index.js | 0 .../x/comments-text/comments-text.html | 0 .../modules/x/comments-text/comments-text.js | 0 .../empty2}/error.txt | 0 .../empty2}/expected.html | 0 .../empty2/index.js | 0 .../x/comments-text/comments-text.html | 0 .../modules/x/comments-text/comments-text.js | 0 .../empty3}/error.txt | 0 .../empty3/expected.html | 7 ++++ .../empty3/index.js | 0 .../x/comments-text/comments-text.html | 0 .../modules/x/comments-text/comments-text.js | 0 .../html-escaping-single}/error.txt | 0 .../html-escaping-single/expected.html | 7 ++++ .../html-escaping-single}/index.js | 0 .../x/comments-text/comments-text.html | 3 ++ .../modules/x/comments-text/comments-text.js | 5 +++ .../html-escaping}/error.txt | 0 .../html-escaping/expected.html | 7 ++++ .../html-escaping}/index.js | 0 .../x/comments-text/comments-text.html | 0 .../modules/x/comments-text/comments-text.js | 7 ++++ .../just-comments}/error.txt | 0 .../just-comments/expected.html | 6 ++++ .../just-comments}/index.js | 0 .../x/comments-text/comments-text.html | 3 ++ .../modules/x/comments-text/comments-text.js | 4 +++ .../nonempty-dynamic}/error.txt | 0 .../nonempty-dynamic/expected.html | 0 .../nonempty-dynamic}/index.js | 0 .../x/comments-text/comments-text.html | 3 ++ .../modules/x/comments-text/comments-text.js | 0 .../nonempty}/error.txt | 0 .../nonempty/expected.html | 0 .../nonempty}/index.js | 0 .../x/comments-text/comments-text.html | 0 .../modules/x/comments-text/comments-text.js | 7 ++++ .../preserve-comments-off/nonempty1/error.txt | 0 .../nonempty1/expected.html | 0 .../nonempty1}/index.js | 0 .../x/comments-text/comments-text.html | 0 .../modules/x/comments-text/comments-text.js | 0 .../preserve-comments-off/nonempty2/error.txt | 0 .../nonempty2/expected.html | 0 .../preserve-comments-off/nonempty2/index.js | 3 ++ .../x/comments-text/comments-text.html | 0 .../modules/x/comments-text/comments-text.js | 0 .../preserve-comments-off/nonempty3/error.txt | 0 .../nonempty3/expected.html | 0 .../preserve-comments-off/nonempty3/index.js | 3 ++ .../x/comments-text/comments-text.html | 0 .../modules/x/comments-text/comments-text.js | 0 .../text-comment-text-comment/error.txt | 0 .../text-comment-text-comment/expected.html | 7 ++++ .../text-comment-text-comment/index.js | 3 ++ .../x/comments-text/comments-text.html | 3 ++ .../modules/x/comments-text/comments-text.js | 7 ++++ .../comments-then-element/error.txt | 0 .../comments-then-element/expected.html | 12 +++++++ .../comments-then-element/index.js | 3 ++ .../x/comments-text/comments-text.html | 3 ++ .../modules/x/comments-text/comments-text.js | 7 ++++ .../emptier-with-text-comment-text/error.txt | 0 .../expected.html | 15 ++++++++ .../emptier-with-text-comment-text/index.js | 3 ++ .../x/comments-text/comments-text.html | 3 ++ .../modules/x/comments-text/comments-text.js | 7 ++++ .../preserve-comments-on/emptier/error.txt | 0 .../emptier/expected.html | 10 ++++++ .../preserve-comments-on/emptier/index.js | 3 ++ .../x/comments-text/comments-text.html | 3 ++ .../modules/x/comments-text/comments-text.js | 7 ++++ .../just-comments/error.txt | 0 .../just-comments/expected.html | 9 +++++ .../just-comments/index.js | 3 ++ .../x/comments-text/comments-text.html | 3 ++ .../modules/x/comments-text/comments-text.js | 4 +++ .../preserve-comments/error.txt | 0 .../preserve-comments/expected.html | 0 .../preserve-comments/index.js | 3 ++ .../x/comments-text/comments-text.html | 0 .../modules/x/comments-text/comments-text.js | 0 .../preserve-comments2/error.txt | 0 .../preserve-comments2/expected.html | 0 .../preserve-comments2/index.js | 3 ++ .../x/comments-text/comments-text.html | 0 .../modules/x/comments-text/comments-text.js | 0 .../preserve-comments3/error.txt | 0 .../preserve-comments3/expected.html | 0 .../preserve-comments3/index.js | 3 ++ .../x/comments-text/comments-text.html | 0 .../modules/x/comments-text/comments-text.js | 0 .../src/compile-template/shared.ts | 22 ++++++++++++ .../compile-template/transformers/comment.ts | 17 ++++++++- .../src/compile-template/transformers/text.ts | 35 +++++-------------- packages/@lwc/ssr-runtime/src/index.ts | 7 ++-- .../ssr-runtime/src/isolate-text-nodes.ts | 17 --------- packages/@lwc/ssr-runtime/src/text-nodes.ts | 33 +++++++++++++++++ 122 files changed, 295 insertions(+), 47 deletions(-) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{emptier/error.txt => .only} (100%) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{empty => preserve-comments-off/comments-at-end}/error.txt (100%) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{emptier => preserve-comments-off/comments-at-end}/expected.html (100%) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{emptier => preserve-comments-off/comments-at-end}/index.js (100%) create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/comments-at-end/modules/x/comments-text/comments-text.html rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{emptier => preserve-comments-off/comments-at-end}/modules/x/comments-text/comments-text.js (100%) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{nonempty-dynamic => preserve-comments-off/comments-then-element}/error.txt (100%) create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/comments-then-element/expected.html rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{empty => preserve-comments-off/comments-then-element}/index.js (100%) create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/comments-then-element/modules/x/comments-text/comments-text.html rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{empty => preserve-comments-off/comments-then-element}/modules/x/comments-text/comments-text.js (100%) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{nonempty => preserve-comments-off/emptier}/error.txt (100%) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{empty => preserve-comments-off/emptier}/expected.html (100%) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{nonempty-dynamic => preserve-comments-off/emptier}/index.js (100%) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{ => preserve-comments-off}/emptier/modules/x/comments-text/comments-text.html (100%) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{nonempty => preserve-comments-off/emptier}/modules/x/comments-text/comments-text.js (100%) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments/empty1 => preserve-comments-off/empty}/error.txt (100%) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments/empty1 => preserve-comments-off/empty}/expected.html (100%) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{nonempty => preserve-comments-off/empty}/index.js (100%) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{ => preserve-comments-off}/empty/modules/x/comments-text/comments-text.html (100%) create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty/modules/x/comments-text/comments-text.js rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments/empty2 => preserve-comments-off/empty1}/error.txt (100%) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments/empty2 => preserve-comments-off/empty1}/expected.html (100%) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments => preserve-comments-off}/empty1/index.js (100%) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments => preserve-comments-off}/empty1/modules/x/comments-text/comments-text.html (100%) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments => preserve-comments-off}/empty1/modules/x/comments-text/comments-text.js (100%) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments/empty3 => preserve-comments-off/empty2}/error.txt (100%) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments/empty3 => preserve-comments-off/empty2}/expected.html (100%) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments => preserve-comments-off}/empty2/index.js (100%) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments => preserve-comments-off}/empty2/modules/x/comments-text/comments-text.html (100%) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments => preserve-comments-off}/empty2/modules/x/comments-text/comments-text.js (100%) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments/nonempty1 => preserve-comments-off/empty3}/error.txt (100%) create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty3/expected.html rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments => preserve-comments-off}/empty3/index.js (100%) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments => preserve-comments-off}/empty3/modules/x/comments-text/comments-text.html (100%) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments => preserve-comments-off}/empty3/modules/x/comments-text/comments-text.js (100%) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments/nonempty2 => preserve-comments-off/html-escaping-single}/error.txt (100%) create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/html-escaping-single/expected.html rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments/nonempty1 => preserve-comments-off/html-escaping-single}/index.js (100%) create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/html-escaping-single/modules/x/comments-text/comments-text.html create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/html-escaping-single/modules/x/comments-text/comments-text.js rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments/nonempty3 => preserve-comments-off/html-escaping}/error.txt (100%) create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/html-escaping/expected.html rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments/nonempty2 => preserve-comments-off/html-escaping}/index.js (100%) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{nonempty-dynamic => preserve-comments-off/html-escaping}/modules/x/comments-text/comments-text.html (100%) create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/html-escaping/modules/x/comments-text/comments-text.js rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments/preserve-comments => preserve-comments-off/just-comments}/error.txt (100%) create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/just-comments/expected.html rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments/nonempty3 => preserve-comments-off/just-comments}/index.js (100%) create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/just-comments/modules/x/comments-text/comments-text.html create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/just-comments/modules/x/comments-text/comments-text.js rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments/preserve-comments2 => preserve-comments-off/nonempty-dynamic}/error.txt (100%) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{ => preserve-comments-off}/nonempty-dynamic/expected.html (100%) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments/preserve-comments => preserve-comments-off/nonempty-dynamic}/index.js (100%) create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty-dynamic/modules/x/comments-text/comments-text.html rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{ => preserve-comments-off}/nonempty-dynamic/modules/x/comments-text/comments-text.js (100%) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments/preserve-comments3 => preserve-comments-off/nonempty}/error.txt (100%) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{ => preserve-comments-off}/nonempty/expected.html (100%) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments/preserve-comments2 => preserve-comments-off/nonempty}/index.js (100%) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{ => preserve-comments-off}/nonempty/modules/x/comments-text/comments-text.html (100%) create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty/modules/x/comments-text/comments-text.js create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty1/error.txt rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments => preserve-comments-off}/nonempty1/expected.html (100%) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments/preserve-comments3 => preserve-comments-off/nonempty1}/index.js (100%) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments => preserve-comments-off}/nonempty1/modules/x/comments-text/comments-text.html (100%) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments => preserve-comments-off}/nonempty1/modules/x/comments-text/comments-text.js (100%) create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty2/error.txt rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments => preserve-comments-off}/nonempty2/expected.html (100%) create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty2/index.js rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments => preserve-comments-off}/nonempty2/modules/x/comments-text/comments-text.html (100%) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments => preserve-comments-off}/nonempty2/modules/x/comments-text/comments-text.js (100%) create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty3/error.txt rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments => preserve-comments-off}/nonempty3/expected.html (100%) create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty3/index.js rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments => preserve-comments-off}/nonempty3/modules/x/comments-text/comments-text.html (100%) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments => preserve-comments-off}/nonempty3/modules/x/comments-text/comments-text.js (100%) create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/text-comment-text-comment/error.txt create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/text-comment-text-comment/expected.html create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/text-comment-text-comment/index.js create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/text-comment-text-comment/modules/x/comments-text/comments-text.html create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/text-comment-text-comment/modules/x/comments-text/comments-text.js create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/comments-then-element/error.txt create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/comments-then-element/expected.html create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/comments-then-element/index.js create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/comments-then-element/modules/x/comments-text/comments-text.html create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/comments-then-element/modules/x/comments-text/comments-text.js create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/emptier-with-text-comment-text/error.txt create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/emptier-with-text-comment-text/expected.html create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/emptier-with-text-comment-text/index.js create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/emptier-with-text-comment-text/modules/x/comments-text/comments-text.html create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/emptier-with-text-comment-text/modules/x/comments-text/comments-text.js create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/emptier/error.txt create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/emptier/expected.html create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/emptier/index.js create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/emptier/modules/x/comments-text/comments-text.html create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/emptier/modules/x/comments-text/comments-text.js create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/just-comments/error.txt create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/just-comments/expected.html create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/just-comments/index.js create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/just-comments/modules/x/comments-text/comments-text.html create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/just-comments/modules/x/comments-text/comments-text.js create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/preserve-comments/error.txt rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments => preserve-comments-on}/preserve-comments/expected.html (100%) create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/preserve-comments/index.js rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments => preserve-comments-on}/preserve-comments/modules/x/comments-text/comments-text.html (100%) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments => preserve-comments-on}/preserve-comments/modules/x/comments-text/comments-text.js (100%) create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/preserve-comments2/error.txt rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments => preserve-comments-on}/preserve-comments2/expected.html (100%) create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/preserve-comments2/index.js rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments => preserve-comments-on}/preserve-comments2/modules/x/comments-text/comments-text.html (100%) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments => preserve-comments-on}/preserve-comments2/modules/x/comments-text/comments-text.js (100%) create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/preserve-comments3/error.txt rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments => preserve-comments-on}/preserve-comments3/expected.html (100%) create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/preserve-comments3/index.js rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments => preserve-comments-on}/preserve-comments3/modules/x/comments-text/comments-text.html (100%) rename packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/{with-comments => preserve-comments-on}/preserve-comments3/modules/x/comments-text/comments-text.js (100%) delete mode 100644 packages/@lwc/ssr-runtime/src/isolate-text-nodes.ts create mode 100644 packages/@lwc/ssr-runtime/src/text-nodes.ts diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/emptier/error.txt b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/.only similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/emptier/error.txt rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/.only diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/empty/error.txt b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/comments-at-end/error.txt similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/empty/error.txt rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/comments-at-end/error.txt diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/emptier/expected.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/comments-at-end/expected.html similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/emptier/expected.html rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/comments-at-end/expected.html diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/emptier/index.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/comments-at-end/index.js similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/emptier/index.js rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/comments-at-end/index.js diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/comments-at-end/modules/x/comments-text/comments-text.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/comments-at-end/modules/x/comments-text/comments-text.html new file mode 100644 index 0000000000..e86e2d4fca --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/comments-at-end/modules/x/comments-text/comments-text.html @@ -0,0 +1,3 @@ + diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/emptier/modules/x/comments-text/comments-text.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/comments-at-end/modules/x/comments-text/comments-text.js similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/emptier/modules/x/comments-text/comments-text.js rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/comments-at-end/modules/x/comments-text/comments-text.js diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/nonempty-dynamic/error.txt b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/comments-then-element/error.txt similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/nonempty-dynamic/error.txt rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/comments-then-element/error.txt diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/comments-then-element/expected.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/comments-then-element/expected.html new file mode 100644 index 0000000000..f821309f78 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/comments-then-element/expected.html @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/empty/index.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/comments-then-element/index.js similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/empty/index.js rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/comments-then-element/index.js diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/comments-then-element/modules/x/comments-text/comments-text.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/comments-then-element/modules/x/comments-text/comments-text.html new file mode 100644 index 0000000000..798c29b64d --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/comments-then-element/modules/x/comments-text/comments-text.html @@ -0,0 +1,3 @@ + diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/empty/modules/x/comments-text/comments-text.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/comments-then-element/modules/x/comments-text/comments-text.js similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/empty/modules/x/comments-text/comments-text.js rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/comments-then-element/modules/x/comments-text/comments-text.js diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/nonempty/error.txt b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/emptier/error.txt similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/nonempty/error.txt rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/emptier/error.txt diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/empty/expected.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/emptier/expected.html similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/empty/expected.html rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/emptier/expected.html diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/nonempty-dynamic/index.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/emptier/index.js similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/nonempty-dynamic/index.js rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/emptier/index.js diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/emptier/modules/x/comments-text/comments-text.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/emptier/modules/x/comments-text/comments-text.html similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/emptier/modules/x/comments-text/comments-text.html rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/emptier/modules/x/comments-text/comments-text.html diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/nonempty/modules/x/comments-text/comments-text.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/emptier/modules/x/comments-text/comments-text.js similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/nonempty/modules/x/comments-text/comments-text.js rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/emptier/modules/x/comments-text/comments-text.js diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/empty1/error.txt b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty/error.txt similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/empty1/error.txt rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty/error.txt diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/empty1/expected.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty/expected.html similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/empty1/expected.html rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty/expected.html diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/nonempty/index.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty/index.js similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/nonempty/index.js rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty/index.js diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/empty/modules/x/comments-text/comments-text.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty/modules/x/comments-text/comments-text.html similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/empty/modules/x/comments-text/comments-text.html rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty/modules/x/comments-text/comments-text.html diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty/modules/x/comments-text/comments-text.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty/modules/x/comments-text/comments-text.js new file mode 100644 index 0000000000..44bf0aff54 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty/modules/x/comments-text/comments-text.js @@ -0,0 +1,7 @@ +import { LightningElement } from 'lwc'; + +export default class extends LightningElement { + foo = ''; + bar = undefined; + baz = null; +} diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/empty2/error.txt b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty1/error.txt similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/empty2/error.txt rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty1/error.txt diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/empty2/expected.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty1/expected.html similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/empty2/expected.html rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty1/expected.html diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/empty1/index.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty1/index.js similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/empty1/index.js rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty1/index.js diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/empty1/modules/x/comments-text/comments-text.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty1/modules/x/comments-text/comments-text.html similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/empty1/modules/x/comments-text/comments-text.html rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty1/modules/x/comments-text/comments-text.html diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/empty1/modules/x/comments-text/comments-text.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty1/modules/x/comments-text/comments-text.js similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/empty1/modules/x/comments-text/comments-text.js rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty1/modules/x/comments-text/comments-text.js diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/empty3/error.txt b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty2/error.txt similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/empty3/error.txt rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty2/error.txt diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/empty3/expected.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty2/expected.html similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/empty3/expected.html rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty2/expected.html diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/empty2/index.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty2/index.js similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/empty2/index.js rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty2/index.js diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/empty2/modules/x/comments-text/comments-text.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty2/modules/x/comments-text/comments-text.html similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/empty2/modules/x/comments-text/comments-text.html rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty2/modules/x/comments-text/comments-text.html diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/empty2/modules/x/comments-text/comments-text.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty2/modules/x/comments-text/comments-text.js similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/empty2/modules/x/comments-text/comments-text.js rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty2/modules/x/comments-text/comments-text.js diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/nonempty1/error.txt b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty3/error.txt similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/nonempty1/error.txt rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty3/error.txt diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty3/expected.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty3/expected.html new file mode 100644 index 0000000000..0e6e634163 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty3/expected.html @@ -0,0 +1,7 @@ + + + \ No newline at end of file diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/empty3/index.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty3/index.js similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/empty3/index.js rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty3/index.js diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/empty3/modules/x/comments-text/comments-text.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty3/modules/x/comments-text/comments-text.html similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/empty3/modules/x/comments-text/comments-text.html rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty3/modules/x/comments-text/comments-text.html diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/empty3/modules/x/comments-text/comments-text.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty3/modules/x/comments-text/comments-text.js similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/empty3/modules/x/comments-text/comments-text.js rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/empty3/modules/x/comments-text/comments-text.js diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/nonempty2/error.txt b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/html-escaping-single/error.txt similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/nonempty2/error.txt rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/html-escaping-single/error.txt diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/html-escaping-single/expected.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/html-escaping-single/expected.html new file mode 100644 index 0000000000..84f3b7dd97 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/html-escaping-single/expected.html @@ -0,0 +1,7 @@ + + + \ No newline at end of file diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/nonempty1/index.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/html-escaping-single/index.js similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/nonempty1/index.js rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/html-escaping-single/index.js diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/html-escaping-single/modules/x/comments-text/comments-text.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/html-escaping-single/modules/x/comments-text/comments-text.html new file mode 100644 index 0000000000..189c0ff634 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/html-escaping-single/modules/x/comments-text/comments-text.html @@ -0,0 +1,3 @@ + diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/html-escaping-single/modules/x/comments-text/comments-text.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/html-escaping-single/modules/x/comments-text/comments-text.js new file mode 100644 index 0000000000..7094659b1c --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/html-escaping-single/modules/x/comments-text/comments-text.js @@ -0,0 +1,5 @@ +import { LightningElement } from 'lwc'; + +export default class extends LightningElement { + foo = '−'; +} diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/nonempty3/error.txt b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/html-escaping/error.txt similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/nonempty3/error.txt rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/html-escaping/error.txt diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/html-escaping/expected.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/html-escaping/expected.html new file mode 100644 index 0000000000..84f3b7dd97 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/html-escaping/expected.html @@ -0,0 +1,7 @@ + + + \ No newline at end of file diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/nonempty2/index.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/html-escaping/index.js similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/nonempty2/index.js rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/html-escaping/index.js diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/nonempty-dynamic/modules/x/comments-text/comments-text.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/html-escaping/modules/x/comments-text/comments-text.html similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/nonempty-dynamic/modules/x/comments-text/comments-text.html rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/html-escaping/modules/x/comments-text/comments-text.html diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/html-escaping/modules/x/comments-text/comments-text.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/html-escaping/modules/x/comments-text/comments-text.js new file mode 100644 index 0000000000..a6255ede18 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/html-escaping/modules/x/comments-text/comments-text.js @@ -0,0 +1,7 @@ +import { LightningElement } from 'lwc'; + +export default class extends LightningElement { + foo = '&'; + bar = 'minus'; + baz = ';'; +} diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/preserve-comments/error.txt b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/just-comments/error.txt similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/preserve-comments/error.txt rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/just-comments/error.txt diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/just-comments/expected.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/just-comments/expected.html new file mode 100644 index 0000000000..9b9b476fdb --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/just-comments/expected.html @@ -0,0 +1,6 @@ + + + \ No newline at end of file diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/nonempty3/index.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/just-comments/index.js similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/nonempty3/index.js rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/just-comments/index.js diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/just-comments/modules/x/comments-text/comments-text.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/just-comments/modules/x/comments-text/comments-text.html new file mode 100644 index 0000000000..e96d3f1bf9 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/just-comments/modules/x/comments-text/comments-text.html @@ -0,0 +1,3 @@ + diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/just-comments/modules/x/comments-text/comments-text.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/just-comments/modules/x/comments-text/comments-text.js new file mode 100644 index 0000000000..bbd55130f4 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/just-comments/modules/x/comments-text/comments-text.js @@ -0,0 +1,4 @@ +import { LightningElement } from 'lwc'; + +export default class extends LightningElement { +} diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/preserve-comments2/error.txt b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty-dynamic/error.txt similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/preserve-comments2/error.txt rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty-dynamic/error.txt diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/nonempty-dynamic/expected.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty-dynamic/expected.html similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/nonempty-dynamic/expected.html rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty-dynamic/expected.html diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/preserve-comments/index.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty-dynamic/index.js similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/preserve-comments/index.js rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty-dynamic/index.js diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty-dynamic/modules/x/comments-text/comments-text.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty-dynamic/modules/x/comments-text/comments-text.html new file mode 100644 index 0000000000..5a0774ecfd --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty-dynamic/modules/x/comments-text/comments-text.html @@ -0,0 +1,3 @@ + diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/nonempty-dynamic/modules/x/comments-text/comments-text.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty-dynamic/modules/x/comments-text/comments-text.js similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/nonempty-dynamic/modules/x/comments-text/comments-text.js rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty-dynamic/modules/x/comments-text/comments-text.js diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/preserve-comments3/error.txt b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty/error.txt similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/preserve-comments3/error.txt rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty/error.txt diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/nonempty/expected.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty/expected.html similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/nonempty/expected.html rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty/expected.html diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/preserve-comments2/index.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty/index.js similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/preserve-comments2/index.js rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty/index.js diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/nonempty/modules/x/comments-text/comments-text.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty/modules/x/comments-text/comments-text.html similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/nonempty/modules/x/comments-text/comments-text.html rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty/modules/x/comments-text/comments-text.html diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty/modules/x/comments-text/comments-text.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty/modules/x/comments-text/comments-text.js new file mode 100644 index 0000000000..44bf0aff54 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty/modules/x/comments-text/comments-text.js @@ -0,0 +1,7 @@ +import { LightningElement } from 'lwc'; + +export default class extends LightningElement { + foo = ''; + bar = undefined; + baz = null; +} diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty1/error.txt b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty1/error.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/nonempty1/expected.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty1/expected.html similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/nonempty1/expected.html rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty1/expected.html diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/preserve-comments3/index.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty1/index.js similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/preserve-comments3/index.js rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty1/index.js diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/nonempty1/modules/x/comments-text/comments-text.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty1/modules/x/comments-text/comments-text.html similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/nonempty1/modules/x/comments-text/comments-text.html rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty1/modules/x/comments-text/comments-text.html diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/nonempty1/modules/x/comments-text/comments-text.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty1/modules/x/comments-text/comments-text.js similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/nonempty1/modules/x/comments-text/comments-text.js rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty1/modules/x/comments-text/comments-text.js diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty2/error.txt b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty2/error.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/nonempty2/expected.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty2/expected.html similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/nonempty2/expected.html rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty2/expected.html diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty2/index.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty2/index.js new file mode 100644 index 0000000000..4bd94488e9 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty2/index.js @@ -0,0 +1,3 @@ +export const tagName = 'x-comments-text'; +export { default } from 'x/comments-text'; +export * from 'x/comments-text'; diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/nonempty2/modules/x/comments-text/comments-text.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty2/modules/x/comments-text/comments-text.html similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/nonempty2/modules/x/comments-text/comments-text.html rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty2/modules/x/comments-text/comments-text.html diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/nonempty2/modules/x/comments-text/comments-text.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty2/modules/x/comments-text/comments-text.js similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/nonempty2/modules/x/comments-text/comments-text.js rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty2/modules/x/comments-text/comments-text.js diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty3/error.txt b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty3/error.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/nonempty3/expected.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty3/expected.html similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/nonempty3/expected.html rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty3/expected.html diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty3/index.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty3/index.js new file mode 100644 index 0000000000..4bd94488e9 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty3/index.js @@ -0,0 +1,3 @@ +export const tagName = 'x-comments-text'; +export { default } from 'x/comments-text'; +export * from 'x/comments-text'; diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/nonempty3/modules/x/comments-text/comments-text.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty3/modules/x/comments-text/comments-text.html similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/nonempty3/modules/x/comments-text/comments-text.html rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty3/modules/x/comments-text/comments-text.html diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/nonempty3/modules/x/comments-text/comments-text.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty3/modules/x/comments-text/comments-text.js similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/nonempty3/modules/x/comments-text/comments-text.js rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty3/modules/x/comments-text/comments-text.js diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/text-comment-text-comment/error.txt b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/text-comment-text-comment/error.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/text-comment-text-comment/expected.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/text-comment-text-comment/expected.html new file mode 100644 index 0000000000..0e6e634163 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/text-comment-text-comment/expected.html @@ -0,0 +1,7 @@ + + + \ No newline at end of file diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/text-comment-text-comment/index.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/text-comment-text-comment/index.js new file mode 100644 index 0000000000..4bd94488e9 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/text-comment-text-comment/index.js @@ -0,0 +1,3 @@ +export const tagName = 'x-comments-text'; +export { default } from 'x/comments-text'; +export * from 'x/comments-text'; diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/text-comment-text-comment/modules/x/comments-text/comments-text.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/text-comment-text-comment/modules/x/comments-text/comments-text.html new file mode 100644 index 0000000000..da33aa2cbf --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/text-comment-text-comment/modules/x/comments-text/comments-text.html @@ -0,0 +1,3 @@ + diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/text-comment-text-comment/modules/x/comments-text/comments-text.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/text-comment-text-comment/modules/x/comments-text/comments-text.js new file mode 100644 index 0000000000..44bf0aff54 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/text-comment-text-comment/modules/x/comments-text/comments-text.js @@ -0,0 +1,7 @@ +import { LightningElement } from 'lwc'; + +export default class extends LightningElement { + foo = ''; + bar = undefined; + baz = null; +} diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/comments-then-element/error.txt b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/comments-then-element/error.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/comments-then-element/expected.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/comments-then-element/expected.html new file mode 100644 index 0000000000..f3d70401af --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/comments-then-element/expected.html @@ -0,0 +1,12 @@ + + + \ No newline at end of file diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/comments-then-element/index.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/comments-then-element/index.js new file mode 100644 index 0000000000..4bd94488e9 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/comments-then-element/index.js @@ -0,0 +1,3 @@ +export const tagName = 'x-comments-text'; +export { default } from 'x/comments-text'; +export * from 'x/comments-text'; diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/comments-then-element/modules/x/comments-text/comments-text.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/comments-then-element/modules/x/comments-text/comments-text.html new file mode 100644 index 0000000000..72c2e48281 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/comments-then-element/modules/x/comments-text/comments-text.html @@ -0,0 +1,3 @@ + diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/comments-then-element/modules/x/comments-text/comments-text.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/comments-then-element/modules/x/comments-text/comments-text.js new file mode 100644 index 0000000000..44bf0aff54 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/comments-then-element/modules/x/comments-text/comments-text.js @@ -0,0 +1,7 @@ +import { LightningElement } from 'lwc'; + +export default class extends LightningElement { + foo = ''; + bar = undefined; + baz = null; +} diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/emptier-with-text-comment-text/error.txt b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/emptier-with-text-comment-text/error.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/emptier-with-text-comment-text/expected.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/emptier-with-text-comment-text/expected.html new file mode 100644 index 0000000000..0b67b66ca9 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/emptier-with-text-comment-text/expected.html @@ -0,0 +1,15 @@ + + + \ No newline at end of file diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/emptier-with-text-comment-text/index.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/emptier-with-text-comment-text/index.js new file mode 100644 index 0000000000..4bd94488e9 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/emptier-with-text-comment-text/index.js @@ -0,0 +1,3 @@ +export const tagName = 'x-comments-text'; +export { default } from 'x/comments-text'; +export * from 'x/comments-text'; diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/emptier-with-text-comment-text/modules/x/comments-text/comments-text.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/emptier-with-text-comment-text/modules/x/comments-text/comments-text.html new file mode 100644 index 0000000000..98cd0cde7b --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/emptier-with-text-comment-text/modules/x/comments-text/comments-text.html @@ -0,0 +1,3 @@ + diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/emptier-with-text-comment-text/modules/x/comments-text/comments-text.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/emptier-with-text-comment-text/modules/x/comments-text/comments-text.js new file mode 100644 index 0000000000..44bf0aff54 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/emptier-with-text-comment-text/modules/x/comments-text/comments-text.js @@ -0,0 +1,7 @@ +import { LightningElement } from 'lwc'; + +export default class extends LightningElement { + foo = ''; + bar = undefined; + baz = null; +} diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/emptier/error.txt b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/emptier/error.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/emptier/expected.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/emptier/expected.html new file mode 100644 index 0000000000..b4d5bbd885 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/emptier/expected.html @@ -0,0 +1,10 @@ + + + \ No newline at end of file diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/emptier/index.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/emptier/index.js new file mode 100644 index 0000000000..4bd94488e9 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/emptier/index.js @@ -0,0 +1,3 @@ +export const tagName = 'x-comments-text'; +export { default } from 'x/comments-text'; +export * from 'x/comments-text'; diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/emptier/modules/x/comments-text/comments-text.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/emptier/modules/x/comments-text/comments-text.html new file mode 100644 index 0000000000..6faada2d46 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/emptier/modules/x/comments-text/comments-text.html @@ -0,0 +1,3 @@ + diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/emptier/modules/x/comments-text/comments-text.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/emptier/modules/x/comments-text/comments-text.js new file mode 100644 index 0000000000..44bf0aff54 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/emptier/modules/x/comments-text/comments-text.js @@ -0,0 +1,7 @@ +import { LightningElement } from 'lwc'; + +export default class extends LightningElement { + foo = ''; + bar = undefined; + baz = null; +} diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/just-comments/error.txt b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/just-comments/error.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/just-comments/expected.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/just-comments/expected.html new file mode 100644 index 0000000000..8958106119 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/just-comments/expected.html @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/just-comments/index.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/just-comments/index.js new file mode 100644 index 0000000000..4bd94488e9 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/just-comments/index.js @@ -0,0 +1,3 @@ +export const tagName = 'x-comments-text'; +export { default } from 'x/comments-text'; +export * from 'x/comments-text'; diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/just-comments/modules/x/comments-text/comments-text.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/just-comments/modules/x/comments-text/comments-text.html new file mode 100644 index 0000000000..285aa302d5 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/just-comments/modules/x/comments-text/comments-text.html @@ -0,0 +1,3 @@ + diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/just-comments/modules/x/comments-text/comments-text.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/just-comments/modules/x/comments-text/comments-text.js new file mode 100644 index 0000000000..bbd55130f4 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/just-comments/modules/x/comments-text/comments-text.js @@ -0,0 +1,4 @@ +import { LightningElement } from 'lwc'; + +export default class extends LightningElement { +} diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/preserve-comments/error.txt b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/preserve-comments/error.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/preserve-comments/expected.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/preserve-comments/expected.html similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/preserve-comments/expected.html rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/preserve-comments/expected.html diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/preserve-comments/index.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/preserve-comments/index.js new file mode 100644 index 0000000000..4bd94488e9 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/preserve-comments/index.js @@ -0,0 +1,3 @@ +export const tagName = 'x-comments-text'; +export { default } from 'x/comments-text'; +export * from 'x/comments-text'; diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/preserve-comments/modules/x/comments-text/comments-text.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/preserve-comments/modules/x/comments-text/comments-text.html similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/preserve-comments/modules/x/comments-text/comments-text.html rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/preserve-comments/modules/x/comments-text/comments-text.html diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/preserve-comments/modules/x/comments-text/comments-text.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/preserve-comments/modules/x/comments-text/comments-text.js similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/preserve-comments/modules/x/comments-text/comments-text.js rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/preserve-comments/modules/x/comments-text/comments-text.js diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/preserve-comments2/error.txt b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/preserve-comments2/error.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/preserve-comments2/expected.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/preserve-comments2/expected.html similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/preserve-comments2/expected.html rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/preserve-comments2/expected.html diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/preserve-comments2/index.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/preserve-comments2/index.js new file mode 100644 index 0000000000..4bd94488e9 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/preserve-comments2/index.js @@ -0,0 +1,3 @@ +export const tagName = 'x-comments-text'; +export { default } from 'x/comments-text'; +export * from 'x/comments-text'; diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/preserve-comments2/modules/x/comments-text/comments-text.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/preserve-comments2/modules/x/comments-text/comments-text.html similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/preserve-comments2/modules/x/comments-text/comments-text.html rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/preserve-comments2/modules/x/comments-text/comments-text.html diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/preserve-comments2/modules/x/comments-text/comments-text.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/preserve-comments2/modules/x/comments-text/comments-text.js similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/preserve-comments2/modules/x/comments-text/comments-text.js rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/preserve-comments2/modules/x/comments-text/comments-text.js diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/preserve-comments3/error.txt b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/preserve-comments3/error.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/preserve-comments3/expected.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/preserve-comments3/expected.html similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/preserve-comments3/expected.html rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/preserve-comments3/expected.html diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/preserve-comments3/index.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/preserve-comments3/index.js new file mode 100644 index 0000000000..4bd94488e9 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/preserve-comments3/index.js @@ -0,0 +1,3 @@ +export const tagName = 'x-comments-text'; +export { default } from 'x/comments-text'; +export * from 'x/comments-text'; diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/preserve-comments3/modules/x/comments-text/comments-text.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/preserve-comments3/modules/x/comments-text/comments-text.html similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/preserve-comments3/modules/x/comments-text/comments-text.html rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/preserve-comments3/modules/x/comments-text/comments-text.html diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/preserve-comments3/modules/x/comments-text/comments-text.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/preserve-comments3/modules/x/comments-text/comments-text.js similarity index 100% rename from packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/with-comments/preserve-comments3/modules/x/comments-text/comments-text.js rename to packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/preserve-comments3/modules/x/comments-text/comments-text.js diff --git a/packages/@lwc/ssr-compiler/src/compile-template/shared.ts b/packages/@lwc/ssr-compiler/src/compile-template/shared.ts index 32d36e0a3e..97fadaacb3 100644 --- a/packages/@lwc/ssr-compiler/src/compile-template/shared.ts +++ b/packages/@lwc/ssr-compiler/src/compile-template/shared.ts @@ -145,3 +145,25 @@ export function getChildAttrsOrProps( return b.objectExpression(objectAttrsOrProps); } + +/** + * True if we should flush at the end of a series of text content nodes and/or comment nodes + * that are adjacent to one another as siblings. (Comment nodes are ignored when preserve-comments + * is turned off.) This allows for adjacent text node concatenation. + * @param cxt - TransformerContext + */ +export const shouldFlushTextContent = (cxt: TransformerContext) => { + const { nextSibling } = cxt; + if (!nextSibling) { + // we are the last sibling + return true + } + switch (nextSibling.type) { + case 'Text': + return false; + case 'Comment': + return cxt.templateOptions.preserveComments; + default: + return true; + } +}; diff --git a/packages/@lwc/ssr-compiler/src/compile-template/transformers/comment.ts b/packages/@lwc/ssr-compiler/src/compile-template/transformers/comment.ts index 1e85d4fd43..0cd9d5004b 100644 --- a/packages/@lwc/ssr-compiler/src/compile-template/transformers/comment.ts +++ b/packages/@lwc/ssr-compiler/src/compile-template/transformers/comment.ts @@ -7,13 +7,28 @@ import { builders as b } from 'estree-toolkit'; +import { esTemplateWithYield } from '../../estemplate'; +import { shouldFlushTextContent } from '../shared'; +import type { Statement as EsStatement} from 'estree' import type { Comment as IrComment } from '@lwc/template-compiler'; import type { Transformer } from '../types'; +const bFlushTextContent = esTemplateWithYield` + yield flushTextContent(); +` + export const Comment: Transformer = function Comment(node, cxt) { if (cxt.templateOptions.preserveComments) { return [b.expressionStatement(b.yieldExpression(b.literal(``)))]; + } else if (shouldFlushTextContent(cxt)) { + // If preserve comments is off, we check if we should flush text content + // for adjacent text nodes. (If preserve comments is on, then the previous + // text node already flushed.) + cxt.import('flushTextContent') + return [ + bFlushTextContent() + ]; } else { - return []; + return [] } }; diff --git a/packages/@lwc/ssr-compiler/src/compile-template/transformers/text.ts b/packages/@lwc/ssr-compiler/src/compile-template/transformers/text.ts index a1782e584f..5e4703f137 100644 --- a/packages/@lwc/ssr-compiler/src/compile-template/transformers/text.ts +++ b/packages/@lwc/ssr-compiler/src/compile-template/transformers/text.ts @@ -9,31 +9,27 @@ import { builders as b, is } from 'estree-toolkit'; import { esTemplateWithYield } from '../../estemplate'; import { expressionIrToEs } from '../expression'; +import { shouldFlushTextContent } from '../shared'; import type { Expression as EsExpression, Statement as EsStatement, - BlockStatement as EsBlockStatement, } from 'estree'; import type { ComplexExpression as IrComplexExpression, Expression as IrExpression, Literal as IrLiteral, Text as IrText, - Node as IrNode, } from '@lwc/template-compiler'; import type { Transformer } from '../types'; const bYield = (expr: EsExpression) => b.expressionStatement(b.yieldExpression(expr)); -const bYieldEscapedString = esTemplateWithYield` - { - const value = ${/* string value */ is.expression}; - // Using non strict equality to align with original implementation (ex. undefined == null) - // See: https://github.com/salesforce/lwc/blob/348130f/packages/%40lwc/engine-core/src/framework/api.ts#L548 - const massagedValue = value == null ? '' : String(value); - yield ${/* is isolated text node? */ is.literal} && massagedValue === '' ? '\\u200D' : htmlEscape(massagedValue); +const bYieldTextContent = esTemplateWithYield` + enqueueTextContent(${/* string value */ is.expression}); + if (${/* should flush */ is.literal}) { + yield flushTextContent(); } -`; +`; function isLiteral(node: IrLiteral | IrExpression | IrComplexExpression): node is IrLiteral { return node.type === 'Literal'; @@ -44,23 +40,8 @@ export const Text: Transformer = function Text(node, cxt): EsStatement[] return [bYield(b.literal(node.value.value))]; } - const shouldIsolate = (node?: IrNode) => { - switch (node?.type) { - case 'Text': - return false; - case 'Comment': - return cxt.templateOptions.preserveComments; - default: - return true; - } - }; - - const isIsolatedTextNode = b.literal( - shouldIsolate(cxt.prevSibling) && shouldIsolate(cxt.nextSibling) - ); - const valueToYield = expressionIrToEs(node.value, cxt); - cxt.import('htmlEscape'); - return [bYieldEscapedString(valueToYield, isIsolatedTextNode)]; + cxt.import(['enqueueTextContent', 'flushTextContent']); + return [bYieldTextContent(valueToYield, b.literal(shouldFlushTextContent(cxt)))]; }; diff --git a/packages/@lwc/ssr-runtime/src/index.ts b/packages/@lwc/ssr-runtime/src/index.ts index 78598b43df..dc2f97b05d 100644 --- a/packages/@lwc/ssr-runtime/src/index.ts +++ b/packages/@lwc/ssr-runtime/src/index.ts @@ -11,7 +11,7 @@ export * from './stubs'; export { htmlEscape, setHooks, sanitizeHtmlContent, normalizeClass } from '@lwc/shared'; export { ClassList } from './class-list'; -export {} from './isolate-text-nodes'; +export { getReadOnlyProxy } from './get-read-only-proxy'; export { LightningElement, LightningElementConstructor, @@ -34,5 +34,8 @@ export { export { hasScopedStaticStylesheets, renderStylesheets } from './styles'; export { toIteratorDirective } from './to-iterator-directive'; export { validateStyleTextContents } from './validate-style-text-contents'; -export { getReadOnlyProxy } from './get-read-only-proxy'; +export { + enqueueTextContent, + flushTextContent +} from './text-nodes'; export { createContextProvider, establishContextfulRelationship, connectContext } from './wire'; diff --git a/packages/@lwc/ssr-runtime/src/isolate-text-nodes.ts b/packages/@lwc/ssr-runtime/src/isolate-text-nodes.ts deleted file mode 100644 index 286d4f1337..0000000000 --- a/packages/@lwc/ssr-runtime/src/isolate-text-nodes.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2024, Salesforce, Inc. - * All rights reserved. - * SPDX-License-Identifier: MIT - * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT - */ -let buffer = ''; - -export function enqueueTextContent(str: string) { - buffer += str; -} - -export function flushTextContent() { - const result = buffer === '' ? '\u200D' : buffer; - buffer = ''; - return result; -} diff --git a/packages/@lwc/ssr-runtime/src/text-nodes.ts b/packages/@lwc/ssr-runtime/src/text-nodes.ts new file mode 100644 index 0000000000..b3537f1960 --- /dev/null +++ b/packages/@lwc/ssr-runtime/src/text-nodes.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024, Salesforce, Inc. + * All rights reserved. + * SPDX-License-Identifier: MIT + * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT + */ +import { htmlEscape } from '@lwc/shared'; + +// Zero Width Joiner character. Special character used by SSR/hydration as +// a placeholder for empty text nodes. +const ZWJ = '\u200D' + +let buffer = ''; +let active = false; + +// Buffer a new string of text node content to be rendered concatenated together +export function enqueueTextContent(value: string) { + // Using non strict equality to align with original implementation (ex. undefined == null) + // See: https://github.com/salesforce/lwc/blob/348130f/packages/%40lwc/engine-core/src/framework/api.ts#L548 + buffer += value == null ? '' : String(value); + active = true; +} + +// We are at the end of a series of text nodes - flush to a concatenated string +export function flushTextContent() { + // We only render the ZWJ if there were actually any dynamic text nodes rendered + // The ZWJ is just so hydration can compare the SSR'd dynamic text content against + // the CSR'd text content. + const result = active && buffer === '' ? ZWJ : htmlEscape(buffer); + buffer = ''; + active = false; + return result; +} From 4a001daca36ddb65e626930d55e3ab0d04b05035 Mon Sep 17 00:00:00 2001 From: John Hefferman Date: Wed, 27 Nov 2024 14:32:01 -0700 Subject: [PATCH 03/13] fix: changed literal text to use same logic as dynamic + tests --- .../fixtures/adjacent-text-nodes/.only | 0 .../modules/x/comments-text/comments-text.js | 3 +-- .../modules/x/comments-text/comments-text.js | 3 +-- .../src/compile-template/shared.ts | 2 +- .../compile-template/transformers/comment.ts | 12 +++++------ .../src/compile-template/transformers/text.ts | 21 +++++++------------ packages/@lwc/ssr-runtime/src/index.ts | 5 +---- packages/@lwc/ssr-runtime/src/text-nodes.ts | 2 +- 8 files changed, 17 insertions(+), 31 deletions(-) delete mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/.only diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/.only b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/.only deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/just-comments/modules/x/comments-text/comments-text.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/just-comments/modules/x/comments-text/comments-text.js index bbd55130f4..ca8dce94e0 100644 --- a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/just-comments/modules/x/comments-text/comments-text.js +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/just-comments/modules/x/comments-text/comments-text.js @@ -1,4 +1,3 @@ import { LightningElement } from 'lwc'; -export default class extends LightningElement { -} +export default class extends LightningElement {} diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/just-comments/modules/x/comments-text/comments-text.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/just-comments/modules/x/comments-text/comments-text.js index bbd55130f4..ca8dce94e0 100644 --- a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/just-comments/modules/x/comments-text/comments-text.js +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-on/just-comments/modules/x/comments-text/comments-text.js @@ -1,4 +1,3 @@ import { LightningElement } from 'lwc'; -export default class extends LightningElement { -} +export default class extends LightningElement {} diff --git a/packages/@lwc/ssr-compiler/src/compile-template/shared.ts b/packages/@lwc/ssr-compiler/src/compile-template/shared.ts index 97fadaacb3..6a4aa1879a 100644 --- a/packages/@lwc/ssr-compiler/src/compile-template/shared.ts +++ b/packages/@lwc/ssr-compiler/src/compile-template/shared.ts @@ -156,7 +156,7 @@ export const shouldFlushTextContent = (cxt: TransformerContext) => { const { nextSibling } = cxt; if (!nextSibling) { // we are the last sibling - return true + return true; } switch (nextSibling.type) { case 'Text': diff --git a/packages/@lwc/ssr-compiler/src/compile-template/transformers/comment.ts b/packages/@lwc/ssr-compiler/src/compile-template/transformers/comment.ts index 0cd9d5004b..f72af83531 100644 --- a/packages/@lwc/ssr-compiler/src/compile-template/transformers/comment.ts +++ b/packages/@lwc/ssr-compiler/src/compile-template/transformers/comment.ts @@ -9,13 +9,13 @@ import { builders as b } from 'estree-toolkit'; import { esTemplateWithYield } from '../../estemplate'; import { shouldFlushTextContent } from '../shared'; -import type { Statement as EsStatement} from 'estree' +import type { Statement as EsStatement } from 'estree'; import type { Comment as IrComment } from '@lwc/template-compiler'; import type { Transformer } from '../types'; const bFlushTextContent = esTemplateWithYield` yield flushTextContent(); -` +`; export const Comment: Transformer = function Comment(node, cxt) { if (cxt.templateOptions.preserveComments) { @@ -24,11 +24,9 @@ export const Comment: Transformer = function Comment(node, cxt) { // If preserve comments is off, we check if we should flush text content // for adjacent text nodes. (If preserve comments is on, then the previous // text node already flushed.) - cxt.import('flushTextContent') - return [ - bFlushTextContent() - ]; + cxt.import('flushTextContent'); + return [bFlushTextContent()]; } else { - return [] + return []; } }; diff --git a/packages/@lwc/ssr-compiler/src/compile-template/transformers/text.ts b/packages/@lwc/ssr-compiler/src/compile-template/transformers/text.ts index 5e4703f137..05619b3288 100644 --- a/packages/@lwc/ssr-compiler/src/compile-template/transformers/text.ts +++ b/packages/@lwc/ssr-compiler/src/compile-template/transformers/text.ts @@ -10,10 +10,7 @@ import { esTemplateWithYield } from '../../estemplate'; import { expressionIrToEs } from '../expression'; import { shouldFlushTextContent } from '../shared'; -import type { - Expression as EsExpression, - Statement as EsStatement, -} from 'estree'; +import type { Statement as EsStatement } from 'estree'; import type { ComplexExpression as IrComplexExpression, Expression as IrExpression, @@ -22,26 +19,22 @@ import type { } from '@lwc/template-compiler'; import type { Transformer } from '../types'; -const bYield = (expr: EsExpression) => b.expressionStatement(b.yieldExpression(expr)); - const bYieldTextContent = esTemplateWithYield` enqueueTextContent(${/* string value */ is.expression}); if (${/* should flush */ is.literal}) { yield flushTextContent(); } -`; +`; function isLiteral(node: IrLiteral | IrExpression | IrComplexExpression): node is IrLiteral { return node.type === 'Literal'; } export const Text: Transformer = function Text(node, cxt): EsStatement[] { - if (isLiteral(node.value)) { - return [bYield(b.literal(node.value.value))]; - } - - const valueToYield = expressionIrToEs(node.value, cxt); - cxt.import(['enqueueTextContent', 'flushTextContent']); - return [bYieldTextContent(valueToYield, b.literal(shouldFlushTextContent(cxt)))]; + + const valueToYield = isLiteral(node.value) + ? b.literal(node.value.value) + : expressionIrToEs(node.value, cxt); + return bYieldTextContent(valueToYield, b.literal(shouldFlushTextContent(cxt))); }; diff --git a/packages/@lwc/ssr-runtime/src/index.ts b/packages/@lwc/ssr-runtime/src/index.ts index dc2f97b05d..84a8e06818 100644 --- a/packages/@lwc/ssr-runtime/src/index.ts +++ b/packages/@lwc/ssr-runtime/src/index.ts @@ -34,8 +34,5 @@ export { export { hasScopedStaticStylesheets, renderStylesheets } from './styles'; export { toIteratorDirective } from './to-iterator-directive'; export { validateStyleTextContents } from './validate-style-text-contents'; -export { - enqueueTextContent, - flushTextContent -} from './text-nodes'; +export { enqueueTextContent, flushTextContent } from './text-nodes'; export { createContextProvider, establishContextfulRelationship, connectContext } from './wire'; diff --git a/packages/@lwc/ssr-runtime/src/text-nodes.ts b/packages/@lwc/ssr-runtime/src/text-nodes.ts index b3537f1960..5c5594d53f 100644 --- a/packages/@lwc/ssr-runtime/src/text-nodes.ts +++ b/packages/@lwc/ssr-runtime/src/text-nodes.ts @@ -8,7 +8,7 @@ import { htmlEscape } from '@lwc/shared'; // Zero Width Joiner character. Special character used by SSR/hydration as // a placeholder for empty text nodes. -const ZWJ = '\u200D' +const ZWJ = '\u200D'; let buffer = ''; let active = false; From 44a67cb09635de0827f72d9920b55f4dda584ec0 Mon Sep 17 00:00:00 2001 From: John Hefferman Date: Wed, 27 Nov 2024 14:33:58 -0700 Subject: [PATCH 04/13] fix: add tests --- .../nonempty-literals-outside/error.txt | 0 .../nonempty-literals-outside/expected.html | 7 +++++++ .../nonempty-literals-outside/index.js | 3 +++ .../modules/x/comments-text/comments-text.html | 3 +++ .../modules/x/comments-text/comments-text.js | 7 +++++++ 5 files changed, 20 insertions(+) create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty-literals-outside/error.txt create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty-literals-outside/expected.html create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty-literals-outside/index.js create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty-literals-outside/modules/x/comments-text/comments-text.html create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty-literals-outside/modules/x/comments-text/comments-text.js diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty-literals-outside/error.txt b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty-literals-outside/error.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty-literals-outside/expected.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty-literals-outside/expected.html new file mode 100644 index 0000000000..2996fd08ab --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty-literals-outside/expected.html @@ -0,0 +1,7 @@ + + + \ No newline at end of file diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty-literals-outside/index.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty-literals-outside/index.js new file mode 100644 index 0000000000..4bd94488e9 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty-literals-outside/index.js @@ -0,0 +1,3 @@ +export const tagName = 'x-comments-text'; +export { default } from 'x/comments-text'; +export * from 'x/comments-text'; diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty-literals-outside/modules/x/comments-text/comments-text.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty-literals-outside/modules/x/comments-text/comments-text.html new file mode 100644 index 0000000000..812db11ed2 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty-literals-outside/modules/x/comments-text/comments-text.html @@ -0,0 +1,3 @@ + diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty-literals-outside/modules/x/comments-text/comments-text.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty-literals-outside/modules/x/comments-text/comments-text.js new file mode 100644 index 0000000000..44bf0aff54 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/nonempty-literals-outside/modules/x/comments-text/comments-text.js @@ -0,0 +1,7 @@ +import { LightningElement } from 'lwc'; + +export default class extends LightningElement { + foo = ''; + bar = undefined; + baz = null; +} From 2096d2774ab035e8ed0fae591d0915a71698e802 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Wed, 27 Nov 2024 13:40:36 -0800 Subject: [PATCH 05/13] Update packages/@lwc/ssr-compiler/src/__tests__/fixtures.spec.ts --- packages/@lwc/ssr-compiler/src/__tests__/fixtures.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@lwc/ssr-compiler/src/__tests__/fixtures.spec.ts b/packages/@lwc/ssr-compiler/src/__tests__/fixtures.spec.ts index 8710f59b0d..c949449ff3 100644 --- a/packages/@lwc/ssr-compiler/src/__tests__/fixtures.spec.ts +++ b/packages/@lwc/ssr-compiler/src/__tests__/fixtures.spec.ts @@ -38,7 +38,7 @@ vi.mock('@lwc/ssr-runtime', async () => { return runtime; }); -const SSR_MODE: CompilationMode = 'asyncYield'; +const SSR_MODE: CompilationMode = DEFAULT_SSR_MODE; async function compileFixture({ input, dirname }: { input: string; dirname: string }) { const modulesDir = path.resolve(dirname, './modules'); From 2f76f22785620a9747c3b7df1914d45b57713529 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Wed, 27 Nov 2024 13:41:22 -0800 Subject: [PATCH 06/13] fix: adjacent text nodes are fixed --- .../ssr-compiler/src/__tests__/utils/expected-failures.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/packages/@lwc/ssr-compiler/src/__tests__/utils/expected-failures.ts b/packages/@lwc/ssr-compiler/src/__tests__/utils/expected-failures.ts index 50bf613adf..e1a15ce04c 100644 --- a/packages/@lwc/ssr-compiler/src/__tests__/utils/expected-failures.ts +++ b/packages/@lwc/ssr-compiler/src/__tests__/utils/expected-failures.ts @@ -8,11 +8,6 @@ // We should slowly drive down these test failures or at least document where we expect the failures // TODO [#4815]: enable all SSR v2 tests export const expectedFailures = new Set([ - // 'adjacent-text-nodes/empty/index.js', - 'adjacent-text-nodes/with-comments/empty1/index.js', - 'adjacent-text-nodes/with-comments/empty2/index.js', - 'adjacent-text-nodes/with-comments/empty3/index.js', - 'adjacent-text-nodes/with-comments/preserve-comments2/index.js', 'attribute-aria/dynamic/index.js', 'attribute-class/with-scoped-styles-only-in-child/dynamic/index.js', 'attribute-class/with-scoped-styles/dynamic/index.js', From f7a1e07f4048c1844fff9d9a164c5026c1a64d50 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Wed, 27 Nov 2024 14:51:06 -0800 Subject: [PATCH 07/13] fix: avoid shared state in text buffer --- .../src/__tests__/utils/expected-failures.ts | 1 + .../compile-template/adjacent-text-nodes.ts | 61 +++++++++++++++++++ .../src/compile-template/shared.ts | 28 +-------- .../compile-template/transformers/comment.ts | 29 +++++---- .../src/compile-template/transformers/text.ts | 35 ++++++++--- packages/@lwc/ssr-runtime/src/index.ts | 1 - packages/@lwc/ssr-runtime/src/text-nodes.ts | 33 ---------- 7 files changed, 108 insertions(+), 80 deletions(-) create mode 100644 packages/@lwc/ssr-compiler/src/compile-template/adjacent-text-nodes.ts delete mode 100644 packages/@lwc/ssr-runtime/src/text-nodes.ts diff --git a/packages/@lwc/ssr-compiler/src/__tests__/utils/expected-failures.ts b/packages/@lwc/ssr-compiler/src/__tests__/utils/expected-failures.ts index e1a15ce04c..5487b7de6a 100644 --- a/packages/@lwc/ssr-compiler/src/__tests__/utils/expected-failures.ts +++ b/packages/@lwc/ssr-compiler/src/__tests__/utils/expected-failures.ts @@ -29,6 +29,7 @@ export const expectedFailures = new Set([ 'scoped-slots/mixed-with-light-dom-slots-inside/index.js', 'scoped-slots/mixed-with-light-dom-slots-outside/index.js', 'slot-forwarding/scoped-slots/index.js', + 'slot-not-at-top-level/advanced/ifTrue/light/index.js', 'slot-not-at-top-level/advanced/ifTrue/shadow/index.js', 'slot-not-at-top-level/advanced/lwcIf/light/index.js', 'slot-not-at-top-level/advanced/lwcIf/shadow/index.js', diff --git a/packages/@lwc/ssr-compiler/src/compile-template/adjacent-text-nodes.ts b/packages/@lwc/ssr-compiler/src/compile-template/adjacent-text-nodes.ts new file mode 100644 index 0000000000..bc0d385b85 --- /dev/null +++ b/packages/@lwc/ssr-compiler/src/compile-template/adjacent-text-nodes.ts @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024, Salesforce, Inc. + * All rights reserved. + * SPDX-License-Identifier: MIT + * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT + */ +import { is } from 'estree-toolkit'; +import { esTemplate, esTemplateWithYield } from '../estemplate'; +import type { BlockStatement as EsBlockStatement, Statement as EsStatement } from 'estree'; +import type { TransformerContext } from './types'; +import type { Node as IrNode } from '@lwc/template-compiler'; + +/** + * True if this is one of a series of text content nodes and/or comment node that are adjacent to one another as + * siblings. (Comment nodes are ignored when preserve-comments is turned off.) This allows for adjacent text + * node concatenation. + */ +const isConcatenatedNode = (node: IrNode, cxt: TransformerContext) => { + switch (node.type) { + case 'Text': + return true; + case 'Comment': + return !cxt.templateOptions.preserveComments; + default: + return false; + } +}; + +export const isFirstConcatenatedNode = (cxt: TransformerContext) => { + const { prevSibling } = cxt; + if (!prevSibling) { + // we are the first sibling + return true; + } + return !isConcatenatedNode(prevSibling, cxt); +}; + +export const isLastConcatenatedNode = (cxt: TransformerContext) => { + const { nextSibling } = cxt; + if (!nextSibling) { + // we are the last sibling + return true; + } + return !isConcatenatedNode(nextSibling, cxt); +}; + +export const bDeclareTextContentBuffer = esTemplate` + // Deliberately using var so we can re-declare as many times as we want in the same scope + var textContentBuffer = ''; + var renderedTextContent = ${/* rendered text content */ is.literal}; +`; + +export const bYieldTextContent = esTemplateWithYield` + if (renderedTextContent) { + // We are at the end of a series of text nodes - flush to a concatenated string + // We only render the ZWJ if there were actually any dynamic text nodes rendered + // The ZWJ is just so hydration can compare the SSR'd dynamic text content against + // the CSR'd text content. + yield textContentBuffer === '' ? '\u200D' : htmlEscape(textContentBuffer); + } +`; diff --git a/packages/@lwc/ssr-compiler/src/compile-template/shared.ts b/packages/@lwc/ssr-compiler/src/compile-template/shared.ts index 6a4aa1879a..ed21898c47 100644 --- a/packages/@lwc/ssr-compiler/src/compile-template/shared.ts +++ b/packages/@lwc/ssr-compiler/src/compile-template/shared.ts @@ -12,17 +12,17 @@ import { isValidES3Identifier } from '@babel/types'; import { expressionIrToEs } from './expression'; import type { TransformerContext } from './types'; import type { - Node as IrNode, Attribute as IrAttribute, + Node as IrNode, Property as IrProperty, } from '@lwc/template-compiler'; import type { - Statement as EsStatement, Expression as EsExpression, - MemberExpression as EsMemberExpression, Identifier as EsIdentifier, + MemberExpression as EsMemberExpression, ObjectExpression as EsObjectExpression, Property as EsProperty, + Statement as EsStatement, } from 'estree'; export function optimizeAdjacentYieldStmts(statements: EsStatement[]): EsStatement[] { @@ -145,25 +145,3 @@ export function getChildAttrsOrProps( return b.objectExpression(objectAttrsOrProps); } - -/** - * True if we should flush at the end of a series of text content nodes and/or comment nodes - * that are adjacent to one another as siblings. (Comment nodes are ignored when preserve-comments - * is turned off.) This allows for adjacent text node concatenation. - * @param cxt - TransformerContext - */ -export const shouldFlushTextContent = (cxt: TransformerContext) => { - const { nextSibling } = cxt; - if (!nextSibling) { - // we are the last sibling - return true; - } - switch (nextSibling.type) { - case 'Text': - return false; - case 'Comment': - return cxt.templateOptions.preserveComments; - default: - return true; - } -}; diff --git a/packages/@lwc/ssr-compiler/src/compile-template/transformers/comment.ts b/packages/@lwc/ssr-compiler/src/compile-template/transformers/comment.ts index f72af83531..4c429e4207 100644 --- a/packages/@lwc/ssr-compiler/src/compile-template/transformers/comment.ts +++ b/packages/@lwc/ssr-compiler/src/compile-template/transformers/comment.ts @@ -7,26 +7,31 @@ import { builders as b } from 'estree-toolkit'; -import { esTemplateWithYield } from '../../estemplate'; -import { shouldFlushTextContent } from '../shared'; -import type { Statement as EsStatement } from 'estree'; +import { + bDeclareTextContentBuffer, + bYieldTextContent, + isFirstConcatenatedNode, + isLastConcatenatedNode, +} from '../adjacent-text-nodes'; import type { Comment as IrComment } from '@lwc/template-compiler'; import type { Transformer } from '../types'; -const bFlushTextContent = esTemplateWithYield` - yield flushTextContent(); -`; - export const Comment: Transformer = function Comment(node, cxt) { if (cxt.templateOptions.preserveComments) { return [b.expressionStatement(b.yieldExpression(b.literal(``)))]; - } else if (shouldFlushTextContent(cxt)) { + } else { + cxt.import('htmlEscape'); + + const isFirstInSeries = isFirstConcatenatedNode(cxt); + const isLastInSeries = isLastConcatenatedNode(cxt); + const renderedTextContent = b.literal(false); + // If preserve comments is off, we check if we should flush text content // for adjacent text nodes. (If preserve comments is on, then the previous // text node already flushed.) - cxt.import('flushTextContent'); - return [bFlushTextContent()]; - } else { - return []; + return [ + ...(isFirstInSeries ? bDeclareTextContentBuffer(renderedTextContent) : []), + ...(isLastInSeries ? [bYieldTextContent()] : []), + ]; } }; diff --git a/packages/@lwc/ssr-compiler/src/compile-template/transformers/text.ts b/packages/@lwc/ssr-compiler/src/compile-template/transformers/text.ts index 05619b3288..a45e96c029 100644 --- a/packages/@lwc/ssr-compiler/src/compile-template/transformers/text.ts +++ b/packages/@lwc/ssr-compiler/src/compile-template/transformers/text.ts @@ -9,8 +9,13 @@ import { builders as b, is } from 'estree-toolkit'; import { esTemplateWithYield } from '../../estemplate'; import { expressionIrToEs } from '../expression'; -import { shouldFlushTextContent } from '../shared'; -import type { Statement as EsStatement } from 'estree'; +import { + bDeclareTextContentBuffer, + bYieldTextContent, + isFirstConcatenatedNode, + isLastConcatenatedNode, +} from '../adjacent-text-nodes'; +import type { Statement as EsStatement, BlockStatement as EsBlockStatement } from 'estree'; import type { ComplexExpression as IrComplexExpression, Expression as IrExpression, @@ -19,22 +24,34 @@ import type { } from '@lwc/template-compiler'; import type { Transformer } from '../types'; -const bYieldTextContent = esTemplateWithYield` - enqueueTextContent(${/* string value */ is.expression}); - if (${/* should flush */ is.literal}) { - yield flushTextContent(); +const bBufferTextContent = esTemplateWithYield` + { + renderedTextContent = true; + const value = ${/* string value */ is.expression}; + // Using non strict equality to align with original implementation (ex. undefined == null) + // See: https://github.com/salesforce/lwc/blob/348130f/packages/%40lwc/engine-core/src/framework/api.ts#L548 + textContentBuffer += value == null ? '' : String(value); } -`; +`; function isLiteral(node: IrLiteral | IrExpression | IrComplexExpression): node is IrLiteral { return node.type === 'Literal'; } export const Text: Transformer = function Text(node, cxt): EsStatement[] { - cxt.import(['enqueueTextContent', 'flushTextContent']); + cxt.import('htmlEscape'); + + const isFirstInSeries = isFirstConcatenatedNode(cxt); + const isLastInSeries = isLastConcatenatedNode(cxt); + const renderedTextContent = b.literal(true); const valueToYield = isLiteral(node.value) ? b.literal(node.value.value) : expressionIrToEs(node.value, cxt); - return bYieldTextContent(valueToYield, b.literal(shouldFlushTextContent(cxt))); + + return [ + ...(isFirstInSeries ? bDeclareTextContentBuffer(renderedTextContent) : []), + bBufferTextContent(valueToYield), + ...(isLastInSeries ? [bYieldTextContent()] : []), + ]; }; diff --git a/packages/@lwc/ssr-runtime/src/index.ts b/packages/@lwc/ssr-runtime/src/index.ts index 84a8e06818..ef329a2097 100644 --- a/packages/@lwc/ssr-runtime/src/index.ts +++ b/packages/@lwc/ssr-runtime/src/index.ts @@ -34,5 +34,4 @@ export { export { hasScopedStaticStylesheets, renderStylesheets } from './styles'; export { toIteratorDirective } from './to-iterator-directive'; export { validateStyleTextContents } from './validate-style-text-contents'; -export { enqueueTextContent, flushTextContent } from './text-nodes'; export { createContextProvider, establishContextfulRelationship, connectContext } from './wire'; diff --git a/packages/@lwc/ssr-runtime/src/text-nodes.ts b/packages/@lwc/ssr-runtime/src/text-nodes.ts deleted file mode 100644 index 5c5594d53f..0000000000 --- a/packages/@lwc/ssr-runtime/src/text-nodes.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2024, Salesforce, Inc. - * All rights reserved. - * SPDX-License-Identifier: MIT - * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT - */ -import { htmlEscape } from '@lwc/shared'; - -// Zero Width Joiner character. Special character used by SSR/hydration as -// a placeholder for empty text nodes. -const ZWJ = '\u200D'; - -let buffer = ''; -let active = false; - -// Buffer a new string of text node content to be rendered concatenated together -export function enqueueTextContent(value: string) { - // Using non strict equality to align with original implementation (ex. undefined == null) - // See: https://github.com/salesforce/lwc/blob/348130f/packages/%40lwc/engine-core/src/framework/api.ts#L548 - buffer += value == null ? '' : String(value); - active = true; -} - -// We are at the end of a series of text nodes - flush to a concatenated string -export function flushTextContent() { - // We only render the ZWJ if there were actually any dynamic text nodes rendered - // The ZWJ is just so hydration can compare the SSR'd dynamic text content against - // the CSR'd text content. - const result = active && buffer === '' ? ZWJ : htmlEscape(buffer); - buffer = ''; - active = false; - return result; -} From 1caafbce3483f7a58ce18f5a753d95129764228c Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Wed, 27 Nov 2024 14:54:34 -0800 Subject: [PATCH 08/13] fix: better variable name --- .../src/compile-template/adjacent-text-nodes.ts | 4 ++-- .../src/compile-template/transformers/comment.ts | 4 ++-- .../ssr-compiler/src/compile-template/transformers/text.ts | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/@lwc/ssr-compiler/src/compile-template/adjacent-text-nodes.ts b/packages/@lwc/ssr-compiler/src/compile-template/adjacent-text-nodes.ts index bc0d385b85..65d98a4ea8 100644 --- a/packages/@lwc/ssr-compiler/src/compile-template/adjacent-text-nodes.ts +++ b/packages/@lwc/ssr-compiler/src/compile-template/adjacent-text-nodes.ts @@ -47,11 +47,11 @@ export const isLastConcatenatedNode = (cxt: TransformerContext) => { export const bDeclareTextContentBuffer = esTemplate` // Deliberately using var so we can re-declare as many times as we want in the same scope var textContentBuffer = ''; - var renderedTextContent = ${/* rendered text content */ is.literal}; + var didBufferTextContent = ${/* didBufferTextContent */ is.literal}; `; export const bYieldTextContent = esTemplateWithYield` - if (renderedTextContent) { + if (didBufferTextContent) { // We are at the end of a series of text nodes - flush to a concatenated string // We only render the ZWJ if there were actually any dynamic text nodes rendered // The ZWJ is just so hydration can compare the SSR'd dynamic text content against diff --git a/packages/@lwc/ssr-compiler/src/compile-template/transformers/comment.ts b/packages/@lwc/ssr-compiler/src/compile-template/transformers/comment.ts index 4c429e4207..4a9df5e3e5 100644 --- a/packages/@lwc/ssr-compiler/src/compile-template/transformers/comment.ts +++ b/packages/@lwc/ssr-compiler/src/compile-template/transformers/comment.ts @@ -24,13 +24,13 @@ export const Comment: Transformer = function Comment(node, cxt) { const isFirstInSeries = isFirstConcatenatedNode(cxt); const isLastInSeries = isLastConcatenatedNode(cxt); - const renderedTextContent = b.literal(false); + const didBufferTextContent = b.literal(false); // If preserve comments is off, we check if we should flush text content // for adjacent text nodes. (If preserve comments is on, then the previous // text node already flushed.) return [ - ...(isFirstInSeries ? bDeclareTextContentBuffer(renderedTextContent) : []), + ...(isFirstInSeries ? bDeclareTextContentBuffer(didBufferTextContent) : []), ...(isLastInSeries ? [bYieldTextContent()] : []), ]; } diff --git a/packages/@lwc/ssr-compiler/src/compile-template/transformers/text.ts b/packages/@lwc/ssr-compiler/src/compile-template/transformers/text.ts index a45e96c029..522f692a06 100644 --- a/packages/@lwc/ssr-compiler/src/compile-template/transformers/text.ts +++ b/packages/@lwc/ssr-compiler/src/compile-template/transformers/text.ts @@ -26,7 +26,7 @@ import type { Transformer } from '../types'; const bBufferTextContent = esTemplateWithYield` { - renderedTextContent = true; + didBufferTextContent = true; const value = ${/* string value */ is.expression}; // Using non strict equality to align with original implementation (ex. undefined == null) // See: https://github.com/salesforce/lwc/blob/348130f/packages/%40lwc/engine-core/src/framework/api.ts#L548 @@ -43,14 +43,14 @@ export const Text: Transformer = function Text(node, cxt): EsStatement[] const isFirstInSeries = isFirstConcatenatedNode(cxt); const isLastInSeries = isLastConcatenatedNode(cxt); - const renderedTextContent = b.literal(true); + const didBufferTextContent = b.literal(true); const valueToYield = isLiteral(node.value) ? b.literal(node.value.value) : expressionIrToEs(node.value, cxt); return [ - ...(isFirstInSeries ? bDeclareTextContentBuffer(renderedTextContent) : []), + ...(isFirstInSeries ? bDeclareTextContentBuffer(didBufferTextContent) : []), bBufferTextContent(valueToYield), ...(isLastInSeries ? [bYieldTextContent()] : []), ]; From 791d7015854d5abc8884c339e314ce77bf4cd807 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Wed, 27 Nov 2024 15:00:16 -0800 Subject: [PATCH 09/13] refactor: simplify further --- .../src/compile-template/adjacent-text-nodes.ts | 3 +-- .../src/compile-template/transformers/comment.ts | 3 +-- .../src/compile-template/transformers/text.ts | 11 +++++------ 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/packages/@lwc/ssr-compiler/src/compile-template/adjacent-text-nodes.ts b/packages/@lwc/ssr-compiler/src/compile-template/adjacent-text-nodes.ts index 65d98a4ea8..d0f77b3519 100644 --- a/packages/@lwc/ssr-compiler/src/compile-template/adjacent-text-nodes.ts +++ b/packages/@lwc/ssr-compiler/src/compile-template/adjacent-text-nodes.ts @@ -4,7 +4,6 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { is } from 'estree-toolkit'; import { esTemplate, esTemplateWithYield } from '../estemplate'; import type { BlockStatement as EsBlockStatement, Statement as EsStatement } from 'estree'; import type { TransformerContext } from './types'; @@ -47,7 +46,7 @@ export const isLastConcatenatedNode = (cxt: TransformerContext) => { export const bDeclareTextContentBuffer = esTemplate` // Deliberately using var so we can re-declare as many times as we want in the same scope var textContentBuffer = ''; - var didBufferTextContent = ${/* didBufferTextContent */ is.literal}; + var didBufferTextContent = false; `; export const bYieldTextContent = esTemplateWithYield` diff --git a/packages/@lwc/ssr-compiler/src/compile-template/transformers/comment.ts b/packages/@lwc/ssr-compiler/src/compile-template/transformers/comment.ts index 4a9df5e3e5..8ad9aa7dae 100644 --- a/packages/@lwc/ssr-compiler/src/compile-template/transformers/comment.ts +++ b/packages/@lwc/ssr-compiler/src/compile-template/transformers/comment.ts @@ -24,13 +24,12 @@ export const Comment: Transformer = function Comment(node, cxt) { const isFirstInSeries = isFirstConcatenatedNode(cxt); const isLastInSeries = isLastConcatenatedNode(cxt); - const didBufferTextContent = b.literal(false); // If preserve comments is off, we check if we should flush text content // for adjacent text nodes. (If preserve comments is on, then the previous // text node already flushed.) return [ - ...(isFirstInSeries ? bDeclareTextContentBuffer(didBufferTextContent) : []), + ...(isFirstInSeries ? bDeclareTextContentBuffer() : []), ...(isLastInSeries ? [bYieldTextContent()] : []), ]; } diff --git a/packages/@lwc/ssr-compiler/src/compile-template/transformers/text.ts b/packages/@lwc/ssr-compiler/src/compile-template/transformers/text.ts index 522f692a06..4cba14884c 100644 --- a/packages/@lwc/ssr-compiler/src/compile-template/transformers/text.ts +++ b/packages/@lwc/ssr-compiler/src/compile-template/transformers/text.ts @@ -15,7 +15,7 @@ import { isFirstConcatenatedNode, isLastConcatenatedNode, } from '../adjacent-text-nodes'; -import type { Statement as EsStatement, BlockStatement as EsBlockStatement } from 'estree'; +import type { Statement as EsStatement } from 'estree'; import type { ComplexExpression as IrComplexExpression, Expression as IrExpression, @@ -25,14 +25,14 @@ import type { import type { Transformer } from '../types'; const bBufferTextContent = esTemplateWithYield` + didBufferTextContent = true; { - didBufferTextContent = true; const value = ${/* string value */ is.expression}; // Using non strict equality to align with original implementation (ex. undefined == null) // See: https://github.com/salesforce/lwc/blob/348130f/packages/%40lwc/engine-core/src/framework/api.ts#L548 textContentBuffer += value == null ? '' : String(value); } -`; +`; function isLiteral(node: IrLiteral | IrExpression | IrComplexExpression): node is IrLiteral { return node.type === 'Literal'; @@ -43,15 +43,14 @@ export const Text: Transformer = function Text(node, cxt): EsStatement[] const isFirstInSeries = isFirstConcatenatedNode(cxt); const isLastInSeries = isLastConcatenatedNode(cxt); - const didBufferTextContent = b.literal(true); const valueToYield = isLiteral(node.value) ? b.literal(node.value.value) : expressionIrToEs(node.value, cxt); return [ - ...(isFirstInSeries ? bDeclareTextContentBuffer(didBufferTextContent) : []), - bBufferTextContent(valueToYield), + ...(isFirstInSeries ? bDeclareTextContentBuffer() : []), + ...bBufferTextContent(valueToYield), ...(isLastInSeries ? [bYieldTextContent()] : []), ]; }; From 7161ea41859ed09404d0379660573e6d68a26dc4 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Wed, 27 Nov 2024 15:10:25 -0800 Subject: [PATCH 10/13] test: minimal repro for remaining adjacent text node issue --- .../preserve-comments-off/deep/error.txt | 0 .../preserve-comments-off/deep/expected.html | 7 +++++++ .../preserve-comments-off/deep/index.js | 3 +++ .../deep/modules/x/comments-text/comments-text.html | 9 +++++++++ .../deep/modules/x/comments-text/comments-text.js | 5 +++++ .../src/__tests__/utils/expected-failures.ts | 1 + 6 files changed, 25 insertions(+) create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/deep/error.txt create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/deep/expected.html create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/deep/index.js create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/deep/modules/x/comments-text/comments-text.html create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/deep/modules/x/comments-text/comments-text.js diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/deep/error.txt b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/deep/error.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/deep/expected.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/deep/expected.html new file mode 100644 index 0000000000..dcc1ec185d --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/deep/expected.html @@ -0,0 +1,7 @@ + + + \ No newline at end of file diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/deep/index.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/deep/index.js new file mode 100644 index 0000000000..4bd94488e9 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/deep/index.js @@ -0,0 +1,3 @@ +export const tagName = 'x-comments-text'; +export { default } from 'x/comments-text'; +export * from 'x/comments-text'; diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/deep/modules/x/comments-text/comments-text.html b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/deep/modules/x/comments-text/comments-text.html new file mode 100644 index 0000000000..a6fdb72f8b --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/deep/modules/x/comments-text/comments-text.html @@ -0,0 +1,9 @@ + diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/deep/modules/x/comments-text/comments-text.js b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/deep/modules/x/comments-text/comments-text.js new file mode 100644 index 0000000000..1973a6ccec --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/adjacent-text-nodes/preserve-comments-off/deep/modules/x/comments-text/comments-text.js @@ -0,0 +1,5 @@ +import { LightningElement } from 'lwc'; + +export default class extends LightningElement { + isTrue = true; +} diff --git a/packages/@lwc/ssr-compiler/src/__tests__/utils/expected-failures.ts b/packages/@lwc/ssr-compiler/src/__tests__/utils/expected-failures.ts index 5487b7de6a..5ee04e2b49 100644 --- a/packages/@lwc/ssr-compiler/src/__tests__/utils/expected-failures.ts +++ b/packages/@lwc/ssr-compiler/src/__tests__/utils/expected-failures.ts @@ -8,6 +8,7 @@ // We should slowly drive down these test failures or at least document where we expect the failures // TODO [#4815]: enable all SSR v2 tests export const expectedFailures = new Set([ + 'adjacent-text-nodes/preserve-comments-off/deep/index.js', 'attribute-aria/dynamic/index.js', 'attribute-class/with-scoped-styles-only-in-child/dynamic/index.js', 'attribute-class/with-scoped-styles/dynamic/index.js', From a474f3b6a96c1e405cde5378ba6b5bf41c719013 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Wed, 27 Nov 2024 15:20:05 -0800 Subject: [PATCH 11/13] fix: simplify and fix minimal repro --- .../src/__tests__/utils/expected-failures.ts | 1 - .../compile-template/adjacent-text-nodes.ts | 22 +++++-------------- .../src/compile-template/index.ts | 5 +++++ .../compile-template/transformers/comment.ts | 13 ++--------- .../src/compile-template/transformers/text.ts | 14 ++---------- 5 files changed, 14 insertions(+), 41 deletions(-) diff --git a/packages/@lwc/ssr-compiler/src/__tests__/utils/expected-failures.ts b/packages/@lwc/ssr-compiler/src/__tests__/utils/expected-failures.ts index 5ee04e2b49..5487b7de6a 100644 --- a/packages/@lwc/ssr-compiler/src/__tests__/utils/expected-failures.ts +++ b/packages/@lwc/ssr-compiler/src/__tests__/utils/expected-failures.ts @@ -8,7 +8,6 @@ // We should slowly drive down these test failures or at least document where we expect the failures // TODO [#4815]: enable all SSR v2 tests export const expectedFailures = new Set([ - 'adjacent-text-nodes/preserve-comments-off/deep/index.js', 'attribute-aria/dynamic/index.js', 'attribute-class/with-scoped-styles-only-in-child/dynamic/index.js', 'attribute-class/with-scoped-styles/dynamic/index.js', diff --git a/packages/@lwc/ssr-compiler/src/compile-template/adjacent-text-nodes.ts b/packages/@lwc/ssr-compiler/src/compile-template/adjacent-text-nodes.ts index d0f77b3519..c9d9fd560b 100644 --- a/packages/@lwc/ssr-compiler/src/compile-template/adjacent-text-nodes.ts +++ b/packages/@lwc/ssr-compiler/src/compile-template/adjacent-text-nodes.ts @@ -4,8 +4,8 @@ * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ -import { esTemplate, esTemplateWithYield } from '../estemplate'; -import type { BlockStatement as EsBlockStatement, Statement as EsStatement } from 'estree'; +import { esTemplateWithYield } from '../estemplate'; +import type { BlockStatement as EsBlockStatement } from 'estree'; import type { TransformerContext } from './types'; import type { Node as IrNode } from '@lwc/template-compiler'; @@ -25,15 +25,6 @@ const isConcatenatedNode = (node: IrNode, cxt: TransformerContext) => { } }; -export const isFirstConcatenatedNode = (cxt: TransformerContext) => { - const { prevSibling } = cxt; - if (!prevSibling) { - // we are the first sibling - return true; - } - return !isConcatenatedNode(prevSibling, cxt); -}; - export const isLastConcatenatedNode = (cxt: TransformerContext) => { const { nextSibling } = cxt; if (!nextSibling) { @@ -43,12 +34,6 @@ export const isLastConcatenatedNode = (cxt: TransformerContext) => { return !isConcatenatedNode(nextSibling, cxt); }; -export const bDeclareTextContentBuffer = esTemplate` - // Deliberately using var so we can re-declare as many times as we want in the same scope - var textContentBuffer = ''; - var didBufferTextContent = false; -`; - export const bYieldTextContent = esTemplateWithYield` if (didBufferTextContent) { // We are at the end of a series of text nodes - flush to a concatenated string @@ -56,5 +41,8 @@ export const bYieldTextContent = esTemplateWithYield` // The ZWJ is just so hydration can compare the SSR'd dynamic text content against // the CSR'd text content. yield textContentBuffer === '' ? '\u200D' : htmlEscape(textContentBuffer); + // Reset + textContentBuffer = ''; + didBufferTextContent = false; } `; diff --git a/packages/@lwc/ssr-compiler/src/compile-template/index.ts b/packages/@lwc/ssr-compiler/src/compile-template/index.ts index 5a1448be35..2af47535ac 100644 --- a/packages/@lwc/ssr-compiler/src/compile-template/index.ts +++ b/packages/@lwc/ssr-compiler/src/compile-template/index.ts @@ -28,6 +28,11 @@ const bExportTemplate = esTemplate` Cmp, instance ) { + // Deliberately using let so we can mutate as many times as we want in the same scope. + // These should be scoped to the "tmpl" function however, to avoid conflicts with other templates. + let textContentBuffer = ''; + let didBufferTextContent = false; + const isLightDom = Cmp.renderMode === 'light'; if (!isLightDom) { yield \`