From 6addf3b42ba67d3f1fdc8a0ebe4afc49ce93c21d Mon Sep 17 00:00:00 2001 From: Owen Buckley Date: Mon, 6 Jan 2025 20:42:41 -0500 Subject: [PATCH 1/2] preserve HTML entities in Light DOM HTML text nodes --- src/wcc.js | 3 +- .../light-dom-html-entities.spec.js | 41 +++++++++++++++++++ .../src/components/ctc-block.js | 5 +++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 test/cases/light-dom-html-entities/light-dom-html-entities.spec.js create mode 100644 test/cases/light-dom-html-entities/src/components/ctc-block.js diff --git a/src/wcc.js b/src/wcc.js index c6872393..f5043afd 100644 --- a/src/wcc.js +++ b/src/wcc.js @@ -188,7 +188,8 @@ function renderLightDomChildren(childNodes, iHTML = '') { ? '' : ``; } else if (nodeName === '#text') { - innerHTML += value; + // TODO what about legitimate < content? + innerHTML += value.replace(/ + <h1>Hello from the server rendered users page! 👋</h1> + + `, + [ + new URL('./src/components/ctc-block.js', import.meta.url) + ]); + + rawHtml = html; + }); + + it('should preserve HTML entities', function() { + expect(rawHtml).to.contain('<h1>Hello from the server rendered users page! 👋</h1>'); + }); + }); +}); \ No newline at end of file diff --git a/test/cases/light-dom-html-entities/src/components/ctc-block.js b/test/cases/light-dom-html-entities/src/components/ctc-block.js new file mode 100644 index 00000000..b86b693e --- /dev/null +++ b/test/cases/light-dom-html-entities/src/components/ctc-block.js @@ -0,0 +1,5 @@ +export default class CopyToClipboardBlock extends HTMLElement { + +} + +customElements.define('x-ctc', CopyToClipboardBlock); \ No newline at end of file From 7a7a69051b283531d1bfe3b33a19484760d85790 Mon Sep 17 00:00:00 2001 From: Owen Buckley Date: Mon, 6 Jan 2025 20:43:01 -0500 Subject: [PATCH 2/2] preserve HTML entities in Light DOM HTML text nodes --- .../light-dom-html-entities/light-dom-html-entities.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cases/light-dom-html-entities/light-dom-html-entities.spec.js b/test/cases/light-dom-html-entities/light-dom-html-entities.spec.js index 35ab85dc..0faa5938 100644 --- a/test/cases/light-dom-html-entities/light-dom-html-entities.spec.js +++ b/test/cases/light-dom-html-entities/light-dom-html-entities.spec.js @@ -1,6 +1,6 @@ /* * Use Case - * Run wcc against HTML with Light DOM HTML entities. + * Run wcc against HTML with Light DOM HTML entities in text nodes. * * User Result * Should return the expected HTML with all the HTML entities preserved.