{"id":22489124,"url":"https://github.com/2A5F/shadow","last_synced_at":"2025-08-02T21:32:12.373Z","repository":{"id":34326558,"uuid":"171680554","full_name":"2A5F/shadow","owner":"2A5F","description":"Shadow dom support for Vue","archived":false,"fork":false,"pushed_at":"2024-04-03T17:51:33.000Z","size":355,"stargazers_count":55,"open_issues_count":6,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-29T18:07:03.941Z","etag":null,"topics":["shadow","shadow-dom","shadow-dom-support","vue","vue-component","vue-components","vue-directive","vue-shadow-dom"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/vue-shadow-dom","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/2A5F.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2019-02-20T13:43:39.000Z","updated_at":"2024-11-25T02:14:59.000Z","dependencies_parsed_at":"2024-06-18T18:31:15.600Z","dependency_job_id":null,"html_url":"https://github.com/2A5F/shadow","commit_stats":{"total_commits":99,"total_committers":9,"mean_commits":11.0,"dds":0.6767676767676767,"last_synced_commit":"e524a44bf5ee84cc4d231b621a0c1bdba974a82c"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2A5F%2Fshadow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2A5F%2Fshadow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2A5F%2Fshadow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2A5F%2Fshadow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/2A5F","download_url":"https://codeload.github.com/2A5F/shadow/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228500221,"owners_count":17930020,"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":["shadow","shadow-dom","shadow-dom-support","vue","vue-component","vue-components","vue-directive","vue-shadow-dom"],"created_at":"2024-12-06T17:19:16.219Z","updated_at":"2024-12-06T17:21:30.509Z","avatar_url":"https://github.com/2A5F.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# Shadow\n[![](https://img.shields.io/npm/v/vue-shadow-dom)](https://www.npmjs.com/package/vue-shadow-dom)\n![MIT](https://img.shields.io/github/license/2a5f/shadow)\n[![](https://img.shields.io/badge/Vue-3-brightgreen?style=flat\u0026logo=vue.js)](https://v3.vuejs.org/)  \n***Shadow dom support for Vue***\n\n\u003e ### !!!!!!!!!! important !!!!!!!!!!\n\u003e ### **[For vue2 use 1.x](https://github.com/2A5F/shadow/tree/vue2)**  \n\u003e ```\n\u003e npm i vue-shadow-dom@1\n\u003e ```\n\n## Usage\n\n- typescript / node / bundle tools (vite webpack ...)\n\n  ```\n  npm i vue-shadow-dom\n  ```\n  \n  ```typescript\n  import { createApp } from 'vue'\n  import shadow from 'vue-shadow-dom'\n  \n  const app = createApp(...)\n  app.use(shadow)\n  app.mount(...)\n  ```\n\n- importmap\n\n  ```html\n  \u003chead\u003e\n    \u003cscript type=\"importmap\"\u003e\n      {\n        \"imports\": {\n          \"vue\": \"../path/to/vue.esm-browser.js\",\n          \"vue-shadow-dom\": \"../path/to/shadow.esm-bundler.mjs\"\n        }\n      }\n    \u003c/script\u003e\n  \n    \u003cscript type=\"module\"\u003e\n      import { createApp } from 'vue'\n      import shadow from 'vue-shadow-root'\n  \n      const app = createApp(...)\n      app.use(shadow)\n      app.mount(...)\n    \u003c/script\u003e\n  \u003c/head\u003e\n  ```\n\n- legacy global\n\n  ```html\n  \u003chead\u003e\n    \u003cscript src=\"vue.js\"\u003e\u003c/script\u003e\n    \u003cscript src=\"../path/to/shadow.global.js\"\u003e\u003c/script\u003e\n    \n    \u003cscript\u003e\n      const app = Vue.createApp(...)\n      app.use(shadow)\n      app.mount(...)\n    \u003c/script\u003e\n  \u003c/head\u003e\n  ```\n\n- legacy global esm mixed\n\n  ```html\n  \u003chead\u003e\n    \u003cscript src=\"vue.js\"\u003e\u003c/script\u003e\n    \u003clink rel=\"modulepreload\" href=\"../path/to/shadow.esm-browser.mjs\" /\u003e\n    \n    \u003cscript type=\"module\"\u003e\n      import shadow from '../path/to/shadow.esm-browser.mjs'\n      \n      const app = Vue.createApp(...)\n      app.use(shadow)\n      app.mount(...)\n    \u003c/script\u003e\n  \u003c/head\u003e\n  ```\n\n\n### Files\n\n- `dist/shadow.global.js`  \n  For UMD\n  ```html\n  \u003cscript src=\"vue.js\"\u003e\u003c/script\u003e\n  \u003cscript src=\"../path/to/shadow.global.js\"\u003e\u003c/script\u003e\n  ```\n- `dist/shadow.esm-browser.mjs` | `dist/shadow.esm-browser.prod.mjs`  \n  For browser import, when Vue from global\n  ```html\n  \u003cscript src=\"vue.js\"\u003e\u003c/script\u003e\n  \u003clink rel=\"modulepreload\" href=\"../path/to/shadow.esm-browser.mjs\" /\u003e\n  \u003cscript type=\"module\"\u003e\n    import shadow from '../path/to/shadow.esm-browser.mjs'\n  \u003c/script\u003e\n  ```\n- `dist/shadow.cdn-jsdelivr.mjs` | `shadow.cdn-jsdelivr.prod.mjs`  \n  For browser import, when Vue from cdn\n  ```html\n  \u003clink rel=\"modulepreload\" href=\"https://cdn.jsdelivr.net/npm/vue@3/dist/vue.runtime.esm-browser.js\" /\u003e\n  \u003clink rel=\"modulepreload\" href=\"shadow.cdn-jsdelivr.mjs\" /\u003e\n  \u003cscript type=\"module\"\u003e\n    import shadow from 'shadow.cdn-jsdelivr.mjs'\n  \u003c/script\u003e\n  ```\n- `dist/shadow.esm-bundler.mjs` | `dist/shadow.esm-bundler.prod.mjs`  \n  For packaging tool or importmap  \n  ```js\n  import shadow from '../path/to/shadow.esm-bundler.mjs'\n  ```\n- `dist/shadow.cjs.cjs` | `dist/shadow.cjs.prod.cjs`  \n  For node cjs  \n  ```js\n  const shadow = require('../path/to/shadow.cjs.prod.cjs') \n  ```\n- `shadow.js`  \n  For node cjs  \n  ```js\n  const shadow = require('vue-shadow-dom') \n  ```\n- `shadow.mjs`  \n  For node esm  \n  ```js\n  import shadow from 'vue-shadow-dom'\n  ```\n\n---\n\n```html\n\u003cdiv v-shadow id=app\u003e\n  \u003cinput\u003e\n  \u003cshadow-root\u003e\n    \u003cdiv\u003e\u003c/div\u003e\n    \u003cp\u003e123\u003c/p\u003e\n  \u003c/shadow-root\u003e\n\u003c/div\u003e\n```\nWill output\n```html\n▼ \u003cdiv id=\"app\"\u003e\n ▼ #shadow-root (open)\n    \u003cinput\u003e\n  ▼ \u003cdiv\u003e\n   ▼ #shadow-root (open)\n      \u003cdiv\u003e\u003c/div\u003e\n      \u003cp\u003e123\u003c/p\u003e\n    \u003c/div\u003e\n  \u003c/div\u003e\n```\n\n## Api\n\n- `\u003cshadow-root\u003e`  \nUsage: \n  ```html\n  \u003cshadow-root\u003e\u003c/shadow-root\u003e\n  ```\n  \n  ### Props\n\n  - `abstract`\n    - type: `boolean`\n    - default: `false`\n\n    it change the location of the #shadow-root  \n    it should not be dynamically changed  \n\n    #### default\n\n    ```html\n    \u003carticle\u003e\n      \u003cshadow-root\u003e\u003cbr\u003e\u003c/shadow-root\u003e\n    \u003c/article\u003e\n    ```\n    ```html\n    ▼ \u003carticle\u003e\n     ▼ \u003cdiv\u003e\n      ▼ #shadow-root (open)\n         \u003cbr\u003e\n      \u003c/article\u003e\n    ```\n\n    #### abstract\n\n    It will make other external tags unavailable\n    ```html\n    \u003carticle\u003e\n      \u003cshadow-root abstract\u003e\u003cbr\u003e\u003c/shadow-root\u003e\n    \u003c/article\u003e\n    ```\n    ```html\n    ▼ \u003carticle\u003e\n     ▼ #shadow-root (open)\n        \u003cbr\u003e\n      \u003c/article\u003e\n    ```\n\n  - `tag`\n    - type: `string`\n    - default: `'div'`\n\n    ```html\n    \u003carticle\u003e\n      \u003cshadow-root tag=\"section\"\u003e\u003cbr\u003e\u003c/shadow-root\u003e\n    \u003c/article\u003e\n    ```\n    ```html\n    ▼ \u003carticle\u003e\n     ▼ \u003csection\u003e\n      ▼ #shadow-root (open)\n         \u003cbr\u003e\n       \u003c/section\u003e\n      \u003c/article\u003e\n    ```\n\n  ### Expose\n\n    ```typescript\n    const ex = ref\u003cShadowRootExpose\u003e()\n    ```\n    ```html\n    \u003cshadow-root ref=\"ex\"\u003e\u003c/shadow-root\u003e\n    ```\n\n  - `shadow_root`  \n   \n    - type: `ShadowRoot`  \n\n    ```typescript\n    const shadow_root: ShadowRoot = ex.shadow_root\n    ```\n\n- `shadow-style`  \n  Usage:  \n  \n  ```html\n  \u003cshadow-style\u003e\u003c/shadow-style\u003e\n  \u003c!-- or --\u003e\n  \u003cShadowRoot.Style\u003e\u003c/ShadowRoot.Style\u003e\n  ```\n\n  Same to html `style`  \n\n  The reason it exists is that vue SFC disabled style tag\n\n- ~~`v-shadow`~~  \n  ***Deprecated***\n\n  Usage: \n  ```html\n  \u003cdiv v-shadow\u003e\u003c/div\u003e\n  ```\n\n- Experimental `adoptedStyleSheets`\n\n  ```js\n  const adoptedStyleSheets = new CSSStyleSheet()\n  adoptedStyleSheets.replace('p { color: green }')\n  ```\n  ```html\n  \u003cshadow-root :adopted-style-sheets=\"[adoptedStyleSheets]\"\u003e\n    \u003cp\u003etest adoptedStyleSheets\u003c/p\u003e\n  \u003c/shadow-root\u003e\n  ```\n  result: ![p is green](./p_is_green.png)\n\n## Build\n\n```\nnpm i\nnpm run build\n```\n\n### Test\n\n```\nnpm run test:dev\nnpm run test:build\nnpm run test:preview\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F2A5F%2Fshadow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F2A5F%2Fshadow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F2A5F%2Fshadow/lists"}