{"id":13657142,"url":"https://github.com/numtel/shadowstyles","last_synced_at":"2025-10-28T07:30:40.324Z","repository":{"id":22600416,"uuid":"25942493","full_name":"numtel/shadowstyles","owner":"numtel","description":"Isolated CSS for simulated Shadow DOM","archived":false,"fork":false,"pushed_at":"2015-05-08T10:36:22.000Z","size":1121,"stargazers_count":8,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-01T12:45:08.684Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/numtel.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}},"created_at":"2014-10-29T21:34:31.000Z","updated_at":"2019-02-22T08:16:39.000Z","dependencies_parsed_at":"2022-08-21T07:31:05.032Z","dependency_job_id":null,"html_url":"https://github.com/numtel/shadowstyles","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/numtel%2Fshadowstyles","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/numtel%2Fshadowstyles/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/numtel%2Fshadowstyles/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/numtel%2Fshadowstyles/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/numtel","download_url":"https://codeload.github.com/numtel/shadowstyles/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238608447,"owners_count":19500379,"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":[],"created_at":"2024-08-02T05:00:37.571Z","updated_at":"2025-10-28T07:30:39.526Z","avatar_url":"https://github.com/numtel.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# Shadow Styles\n\n[![Build Status](https://travis-ci.org/numtel/shadowstyles.svg?branch=master)](https://travis-ci.org/numtel/shadowstyles)\n\nWebComponents bring Shadow DOM with isolated CSS to some browsers.\nThis script simulates CSS isolation for all modern browsers (IE9+, Firefox...).\n\n## Installation\nCommonJS applications may need to include the `mutation-observer` polyfill NPM package as well if they need to support browsers that don't suppport `MutationObserver` natively:\n```\nnpm install mutation-observer shadowstyles\n```\n\nOr downoad the built file and manually add tag:\n```html\n\u003cscript src=\"build/shadowStyles.min.js\"\u003e\u003c/script\u003e\n```\n\n## document.shadowStyles()\nPass one argument: array, string, or element.\nString provides a selector to match new shadow root elements.\nElement provides a direct reference to a root element.\nArray can contain a combination of both.\n\n```javascript\n// Example with selector string only\ndocument.shadowStyles('x-foo');\n\n// Example with array containing both types\ndocument.shadowStyles([\n  'x-foo', // All x-foo elements will have shadow styled children\n  document.getElementById('something') // Specific element\n]);\n```\n\n## Targeting simulated shadows\n\nShadowed elements are given a `shadow` attribute that must be present in the\nselector:\n\n```css\nshadowed-element[shadow] p { color: blue; }\n```\n\n## Detecting native support\n\nWhen using in conjunction with the Platform.js Shadow DOM polyfill, it can be\nuseful to know whether the shadow DOM is emulated. Check the boolean constant:\n\n```javascript\ndocument.shadowStyles.nativeSupport\n```\n\n**Note:** I'm considering wrapping the polyfilled `createShadowRoot()` to\nautomatically isolate the shadow CSS, also allowing `createShadowRoot(false)`\nto skip style isolation. See `test/mockup/webcomponent.html` for implementation\ndetails.\n\n## How it works\n\n1. Search for child DOM of elements to isolate.\n2. Find which rules apply to those elements and add a `:not(buffer-attr*=\"uniqueId\")`\n    pseudo-class with a unique ID to each rule. Shadowed elements gain the buffer\n    attribute containing the unique ID of each negated rule.\n\n### Why not `::shadow`?\n\nOriginally, the plan of this project was to support styles using the native\n`::shadow` pseudo-class syntax. Until the fifteenth commit, this worked, but\nonly if all the page's stylesheets were rewritten completely. By only\nusing selectors that the browser already supports, the script can skip parsing\nall of your CSS itself and rely on the browser's interpretation, only making\nsmall changes as needed. The final result is much smoother operation.\n\n## Still to do\n\n* Handle nested shadow DOM correctly\n\n## Build / Run Tests\n\n```bash\n# Clone repository to current directory\n$ git clone https://github.com/numtel/shadowstyles.git\n$ cd shadowstyles\n$ npm install\n# Install Grunt Client\n$ npm install -g grunt-cli\n\n# Run default operation to build minified file\n$ grunt\n\n# Running tests locally requires Selenium jar in repo\n# http://selenium-release.storage.googleapis.com/index.html\n# For example, 2.45.0:\n$ wget http://selenium-release.storage.googleapis.com/2.45/selenium-server-standalone-2.45.0.jar\n# If not running 2.45.0, update filename in GruntFile.js\n\n# Test using grunt-nightwatch:\n$ grunt nightwatch:local\n# Or use default test command alias:\n$ npm test\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnumtel%2Fshadowstyles","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnumtel%2Fshadowstyles","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnumtel%2Fshadowstyles/lists"}