{"id":18537926,"url":"https://github.com/easywebapp/declarative-shadow-dom-polyfill","last_synced_at":"2025-04-09T17:37:13.681Z","repository":{"id":246988079,"uuid":"823259360","full_name":"EasyWebApp/declarative-shadow-dom-polyfill","owner":"EasyWebApp","description":"Web standard polyfill for Declarative Shadow DOM","archived":false,"fork":false,"pushed_at":"2024-07-25T14:53:54.000Z","size":89,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-24T09:11:34.927Z","etag":null,"topics":["component","dom","polyfill","ssr","standard","w3c","web"],"latest_commit_sha":null,"homepage":"http://web-cell.dev/declarative-shadow-dom-polyfill/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EasyWebApp.png","metadata":{"files":{"readme":"ReadMe.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-02T17:25:43.000Z","updated_at":"2024-11-23T01:01:52.000Z","dependencies_parsed_at":"2024-11-06T19:43:02.198Z","dependency_job_id":"fb332cd2-87c7-477c-b13e-78303523838a","html_url":"https://github.com/EasyWebApp/declarative-shadow-dom-polyfill","commit_stats":null,"previous_names":["easywebapp/declarative-shadow-dom-polyfill"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EasyWebApp%2Fdeclarative-shadow-dom-polyfill","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EasyWebApp%2Fdeclarative-shadow-dom-polyfill/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EasyWebApp%2Fdeclarative-shadow-dom-polyfill/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EasyWebApp%2Fdeclarative-shadow-dom-polyfill/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EasyWebApp","download_url":"https://codeload.github.com/EasyWebApp/declarative-shadow-dom-polyfill/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248078348,"owners_count":21044092,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["component","dom","polyfill","ssr","standard","w3c","web"],"created_at":"2024-11-06T19:41:16.680Z","updated_at":"2025-04-09T17:37:13.406Z","avatar_url":"https://github.com/EasyWebApp.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Declarative Shadow DOM polyfill\n\nWeb standard polyfill for [Declarative Shadow DOM][1]\n\n[![NPM Dependency](https://img.shields.io/librariesio/github/EasyWebApp/declarative-shadow-dom-polyfill.svg)][2]\n[![CI \u0026 CD](https://github.com/EasyWebApp/declarative-shadow-dom-polyfill/actions/workflows/main.yml/badge.svg)][3]\n[![](https://data.jsdelivr.com/v1/package/npm/declarative-shadow-dom-polyfill/badge?style=rounded)][4]\n\n[![NPM](https://nodei.co/npm/declarative-shadow-dom-polyfill.png?downloads=true\u0026downloadRank=true\u0026stars=true)][5]\n\n## Knowledge\n\n1. [Proposal specification][2]\n2. [API documentation][3]\n\n## Usage\n\nAny one of these methods shown below is available.\n\n### 1. CDN\n\n```html\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003cscript src=\"https://polyfill.web-cell.dev/feature/DeclarativeShadowDOM.js\"\u003e\u003c/script\u003e\n\n    \u003cscript src=\"./my-tag.js\"\u003e\u003c/script\u003e\n    \u003cscript\u003e\n      window.onload = () =\u003e {\n        const { shadowRoot } = document.querySelector(\"my-tag\");\n\n        console.log(shadowRoot);\n      };\n    \u003c/script\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003cmy-tag\u003e\n      \u003ctemplate shadowrootmode=\"open\"\u003e\n        \u003cp\u003eHello, Declarative Shadow DOM!\u003c/p\u003e\n      \u003c/template\u003e\n    \u003c/my-tag\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n### 2. Polyfill import\n\n```javascript\nimport \"declarative-shadow-dom-polyfill\";\n\nconst markup = `\n\u003cmy-tag\u003e\n    \u003ctemplate shadowrootmode=\"open\"\u003e\n        \u003cp\u003eHello, Declarative Shadow DOM!\u003c/p\u003e\n    \u003c/template\u003e\n\u003c/my-tag\u003e`;\n\ndocument.body.setHTMLUnsafe(markup);\n\nconsole.log(document.body.getHTML());\n\nconst newDocument = Document.parseHTMLUnsafe(markup);\n\nconsole.log(newDocument.body.getHTML());\n```\n\n### 3. Ponyfill import\n\n```javascript\nimport {\n  getHTML,\n  setHTMLUnsafe,\n  parseHTMLUnsafe,\n} from \"declarative-shadow-dom-polyfill\";\n\nconst markup = `\n\u003cmy-tag\u003e\n    \u003ctemplate shadowrootmode=\"open\"\u003e\n        \u003cp\u003eHello, Declarative Shadow DOM!\u003c/p\u003e\n    \u003c/template\u003e\n\u003c/my-tag\u003e`;\n\nsetHTMLUnsafe.call(document.body, markup);\n\nconsole.log(getHTML.call(document.body));\n\nconst newDocument = parseHTMLUnsafe(markup);\n\nconsole.log(getHTML.call(newDocument.body));\n```\n\n### 4. Node.js \u0026 Bun\n\n#### `global.js`\n\nEither `jsdom`, `happy-dom` or `linkedom` is available DOM implementation.\n\n```javascript\nimport { JSDOM } from \"jsdom\";\n\nconst { window } = new JSDOM(),\n  RequiredAPI = [\n    \"Text\",\n    \"Comment\",\n    \"CDATASection\",\n    \"Element\",\n    \"HTMLElement\",\n    \"SVGElement\",\n    \"ShadowRoot\",\n    \"Document\",\n    \"NodeFilter\",\n    \"XMLSerializer\",\n    \"DOMParser\",\n    \"window\",\n    \"document\",\n  ];\n\nfor (const key of RequiredAPI) Reflect.set(globalThis, key, window[key]);\n```\n\n#### `index.js`\n\n```javascript\nimport \"./global\";\nimport \"declarative-shadow-dom-polyfill\";\n\nconsole.log(document.body.getHTML());\n```\n\n[1]: https://developer.chrome.com/docs/css-ui/declarative-shadow-dom\n[2]: https://libraries.io/npm/declarative-shadow-dom-polyfill\n[3]: https://github.com/EasyWebApp/declarative-shadow-dom-polyfill/actions/workflows/main.yml\n[4]: https://www.jsdelivr.com/package/npm/declarative-shadow-dom-polyfill\n[5]: https://nodei.co/npm/declarative-shadow-dom-polyfill/\n[6]: https://github.com/mfreed7/declarative-shadow-dom\n[7]: https://web-cell.dev/declarative-shadow-dom-polyfill/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feasywebapp%2Fdeclarative-shadow-dom-polyfill","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feasywebapp%2Fdeclarative-shadow-dom-polyfill","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feasywebapp%2Fdeclarative-shadow-dom-polyfill/lists"}