Skip to content

adrianhelvik/anonymous-custom-elements

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Proposal: Anonymous custom elements

This proposal adds the new class AnonymousElement. This class can be extended to create anonymous custom elements.

class MyAnonymousElement extends AnonymousElement {
  connectedCallback() {
    this.textContent = 'I am anonymous'
  }
}

document.body.appendChild(new MyAnonymousElement())

AnonymousElement specification

AnonymousElement extends HTMLElement and inherits all properties not mentioned in this proposal.

tagName

Readonly property containing an empty DOMString.

outerHTML

Returns the same value as innerHTML.

Polyfill usage

WARNING: Do not use in production.

<!doctype html>
<meta charset="utf-8">
<body>
  <script src="http://cdn.jsdelivr.net/gh/adrianhelvik/anonymous-custom-elements/polyfill.js"></script>
  <script>
    class MyAnonymousElement extends AnonymousElement {
      connectedCallback() {
        this.textContent = 'I am anonymous'
      }
    }

    document.body.appendChild(new MyAnonymousElement())
  </script>
</body>

Live example

Polyfill constraints

Does not alter innerHTML, outerHTML or tagName

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published