WebReflection / linkedom

A triple-linked lists based DOM implementation.

Home Page:https://webreflection.medium.com/linkedom-a-jsdom-alternative-53dd8f699311

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HTMLTemplateElement toString does not include contents

saviski opened this issue · comments

get content() {

I see that this related issue is marked as closed #21

But later modifications removed this functionality

I am using this hack locally to get the functionality I need

  const originaltoString = Object.getOwnPropertyDescriptor(Element.prototype, 'toString')!
  Object.defineProperties(HTMLTemplateElement.prototype, {
    toString: {
      value() {
        return (
          originaltoString.value
            .call(this)
            .replace(/<\/template>$/, this.content.childNodes.join('')) + '</template>'
        )
      },
    },
  })

the test works though ... I am not sure when/where/how you are having issues ... can you share a minimal broken example code instead of your fix? thanks!