WebReflection / WebReflection/linkedom

HTMLTemplateElement toString does not include contents

Open
#215 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
2.1k
Forks
104
PR merge metrics
No merged PRs in 30d

Description

https://github.com/WebReflection/linkedom/blob/ec5ce8470c50fe2e9ea6e8b339e6ee4f23077c73/esm/html/template-element.js#L19

I see that this related issue is marked as closed https://github.com/WebReflection/linkedom/issues/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>'
        )
      },
    },
  })

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at esm/html/template-element.js around line 19, where HTMLTemplateElement.toString is defined. Compare its output with the behavior described in the issue and the provided local workaround. Done means toString includes the template contents before the closing tag.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
web-dev
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.