{"_id":"scope-css","_rev":"4128487","name":"scope-css","description":"Scope each css rule with a selector, ie. nest into parent","dist-tags":{"latest":"2.0.0"},"maintainers":[{"name":"dfcreative","email":"df.creative@gmail.com"},{"name":"dy","email":"155263213@qq.com"}],"time":{"modified":"2026-03-01T18:28:02.000Z","created":"2016-07-19T08:16:42.983Z","2.0.0":"2026-01-28T23:12:57.717Z","1.2.1":"2018-10-16T10:07:04.717Z","1.2.0":"2018-10-11T21:10:05.357Z","1.1.1":"2018-10-10T11:36:09.937Z","1.1.0":"2018-04-23T19:54:42.166Z","1.0.5":"2017-11-02T18:05:53.810Z","1.0.4":"2016-07-25T03:24:47.398Z","1.0.3":"2016-07-24T19:51:34.732Z","1.0.2":"2016-07-19T08:33:24.308Z","1.0.1":"2016-07-19T08:28:31.807Z","1.0.0":"2016-07-19T08:16:42.983Z"},"users":{},"author":{"name":"ΔY","email":"df.creative@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/dy/scope-css.git"},"versions":{"2.0.0":{"name":"scope-css","version":"2.0.0","description":"Scope each css rule with a selector, ie. nest into parent","main":"index.js","type":"module","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"git+https://github.com/dy/scope-css.git"},"keywords":["css","style","insert-css","nesting","scope","nest","parent","selector","sheetify"],"author":{"name":"ΔY","email":"df.creative@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/dy/scope-css/issues"},"homepage":"https://github.com/dy/scope-css#readme","devDependencies":{"cln":"^1.1.0","tst":"^9.2.1"},"gitHead":"5036fa0fa1f4c09fdf6724711f4c9556a1c3041c","_id":"scope-css@2.0.0","_nodeVersion":"25.2.1","_npmVersion":"11.6.2","dist":{"shasum":"ee6760de19febe576a16f7a819364578ccb4b2d9","size":2889,"noattachment":false,"key":"/scope-css/-/scope-css-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/scope-css/download/scope-css-2.0.0.tgz"},"_npmUser":{"name":"dfcreative","email":"df.creative@gmail.com"},"directories":{},"maintainers":[{"name":"dfcreative","email":"df.creative@gmail.com"},{"name":"dy","email":"155263213@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/scope-css_2.0.0_1769641977578_0.6453172637567823"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2026-01-28T23:12:57.717Z","publish_time":1769641977717,"_source_registry_name":"default","_cnpm_publish_time":1769641977717},"1.2.1":{"name":"scope-css","version":"1.2.1","description":"Scope each css rule with a selector, ie. nest into parent","main":"index.js","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"git+https://github.com/dy/scope-css.git"},"keywords":["css","style","insert-css","nesting","scope","nest","parent","selector","sheetify"],"author":{"name":"ΔY","email":"df.creative@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/dy/scope-css/issues"},"homepage":"https://github.com/dy/scope-css#readme","devDependencies":{"cln":"^1.1.0","tape":"^4.9.1"},"dependencies":{"escaper":"^2.5.3","slugify":"^1.3.1","strip-css-comments":"^3.0.0"},"gitHead":"59d0ff1739012475ee6b0fdaf3ba2dac5eb10c81","_id":"scope-css@1.2.1","_npmVersion":"6.4.1","_nodeVersion":"8.11.1","_npmUser":{"name":"dfcreative","email":"df.creative@gmail.com"},"dist":{"shasum":"c35768bc900cad030a3e0d663a818c0f6a57f40e","size":2258,"noattachment":false,"key":"/scope-css/-/scope-css-1.2.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/scope-css/download/scope-css-1.2.1.tgz"},"maintainers":[{"name":"dfcreative","email":"df.creative@gmail.com"},{"name":"dy","email":"155263213@qq.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/scope-css_1.2.1_1539684424626_0.18791407062693555"},"_hasShrinkwrap":false,"publish_time":1539684424717,"_cnpm_publish_time":1539684424717,"_cnpmcore_publish_time":"2021-12-16T23:07:41.684Z"},"1.2.0":{"name":"scope-css","version":"1.2.0","description":"Scope each css rule with a selector, ie. nest into parent","main":"index.js","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"git+https://github.com/dy/scope-css.git"},"keywords":["css","style","insert-css","nesting","scope","nest","parent","selector","sheetify"],"author":{"name":"ΔY","email":"df.creative@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/dy/scope-css/issues"},"homepage":"https://github.com/dy/scope-css#readme","devDependencies":{"cln":"^1.1.0","tape":"^4.9.1"},"dependencies":{"slugify":"^1.3.1","strip-css-comments":"^3.0.0"},"gitHead":"9383a8e2dc64eb2cd59035251c949ce4dff9bf80","_id":"scope-css@1.2.0","_npmVersion":"6.4.1","_nodeVersion":"8.11.1","_npmUser":{"name":"dfcreative","email":"df.creative@gmail.com"},"dist":{"shasum":"99ca63bbc09024a151809104586ff6214aa0787d","size":2183,"noattachment":false,"key":"/scope-css/-/scope-css-1.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/scope-css/download/scope-css-1.2.0.tgz"},"maintainers":[{"name":"dfcreative","email":"df.creative@gmail.com"},{"name":"dy","email":"155263213@qq.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/scope-css_1.2.0_1539292205240_0.33929626231554133"},"_hasShrinkwrap":false,"publish_time":1539292205357,"_cnpm_publish_time":1539292205357,"_cnpmcore_publish_time":"2021-12-16T23:07:41.903Z"},"1.1.1":{"name":"scope-css","version":"1.1.1","description":"Scope each css rule with a selector, ie. nest into parent","main":"index.js","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"git+https://github.com/dy/scope-css.git"},"keywords":["css","style","insert-css","nesting","scope","nest","parent","selector","sheetify"],"author":{"name":"ΔY","email":"df.creative@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/dy/scope-css/issues"},"homepage":"https://github.com/dy/scope-css#readme","devDependencies":{"cln":"^1.1.0","tape":"^4.9.1"},"dependencies":{"strip-css-comments":"^3.0.0"},"gitHead":"a5020e5ed42bb7bd200415a440cd178738fa016a","_id":"scope-css@1.1.1","_npmVersion":"6.4.1","_nodeVersion":"8.11.1","_npmUser":{"name":"dfcreative","email":"df.creative@gmail.com"},"dist":{"shasum":"346b4a39f7cb7c8eb242470eeb893f8c354ee1a5","size":1669,"noattachment":false,"key":"/scope-css/-/scope-css-1.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/scope-css/download/scope-css-1.1.1.tgz"},"maintainers":[{"name":"dfcreative","email":"df.creative@gmail.com"},{"name":"dy","email":"155263213@qq.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/scope-css_1.1.1_1539171369622_0.3785418513238705"},"_hasShrinkwrap":false,"publish_time":1539171369937,"_cnpm_publish_time":1539171369937,"_cnpmcore_publish_time":"2021-12-16T23:07:42.082Z"},"1.1.0":{"name":"scope-css","version":"1.1.0","description":"Scope each css rule with specified selector, so to speak apply nesting to parent","main":"index.js","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"git+https://github.com/dy/scope-css.git"},"keywords":["css","style","insert-css","nesting","scope","nest","parent","selector","sheetify"],"author":{"name":"ΔY","email":"df.creative@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/dy/scope-css/issues"},"homepage":"https://github.com/dy/scope-css#readme","gitHead":"731e82a4e7d0a01fd5697d3fbeba653a7ed88539","_id":"scope-css@1.1.0","_npmVersion":"5.6.0","_nodeVersion":"8.1.2","_npmUser":{"name":"dfcreative","email":"df.creative@gmail.com"},"dist":{"shasum":"74eff45461bc9d3f3b29ed575b798cd722fa1256","size":1655,"noattachment":false,"key":"/scope-css/-/scope-css-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/scope-css/download/scope-css-1.1.0.tgz"},"maintainers":[{"name":"dfcreative","email":"df.creative@gmail.com"},{"name":"dy","email":"155263213@qq.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/scope-css_1.1.0_1524513282087_0.5929375798486398"},"_hasShrinkwrap":false,"publish_time":1524513282166,"_cnpm_publish_time":1524513282166,"_cnpmcore_publish_time":"2021-12-16T23:07:42.259Z"},"1.0.5":{"name":"scope-css","version":"1.0.5","description":"Scope each css rule with specified selector, so to speak apply nesting to parent","main":"index.js","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"git+https://github.com/dfcreative/scope-css.git"},"keywords":["css","style","insert-css","nesting","scope","nest","parent","selector","sheetify"],"author":{"name":"ΔY","email":"df.creative@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/dfcreative/scope-css/issues"},"homepage":"https://github.com/dfcreative/scope-css#readme","gitHead":"524c3fc4094526a992405ec6e7080c04dbbb34f5","_id":"scope-css@1.0.5","_shasum":"9a40a959231ecf683dbef3dedae6a26ab091e1fd","_from":".","_npmVersion":"4.6.1","_nodeVersion":"8.1.2","_npmUser":{"name":"dfcreative","email":"df.creative@gmail.com"},"dist":{"shasum":"9a40a959231ecf683dbef3dedae6a26ab091e1fd","size":1587,"noattachment":false,"key":"/scope-css/-/scope-css-1.0.5.tgz","tarball":"http://registry.cnpm.dingdandao.com/scope-css/download/scope-css-1.0.5.tgz"},"maintainers":[{"name":"dfcreative","email":"df.creative@gmail.com"},{"name":"dy","email":"155263213@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/scope-css-1.0.5.tgz_1509645953312_0.21777622308582067"},"directories":{},"publish_time":1509645953810,"_hasShrinkwrap":false,"_cnpm_publish_time":1509645953810,"_cnpmcore_publish_time":"2021-12-16T23:07:42.473Z"},"1.0.4":{"name":"scope-css","version":"1.0.4","description":"Scope each css rule with specified selector, so to speak apply nesting to parent","main":"index.js","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"git+https://github.com/dfcreative/scope-css.git"},"keywords":["css","style","insert-css","nesting","scope","nest","parent","selector","sheetify"],"author":{"name":"ΔY","email":"df.creative@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/dfcreative/scope-css/issues"},"homepage":"https://github.com/dfcreative/scope-css#readme","gitHead":"90f52c6b2a608c742d5333416956b45c0ff103c1","_id":"scope-css@1.0.4","_shasum":"1b127e2cf375ab50acaefecdc045ae79860f4a82","_from":".","_npmVersion":"3.7.2","_nodeVersion":"6.2.0","_npmUser":{"name":"dfcreative","email":"df.creative@gmail.com"},"maintainers":[{"name":"dfcreative","email":"df.creative@gmail.com"},{"name":"dy","email":"155263213@qq.com"}],"dist":{"shasum":"1b127e2cf375ab50acaefecdc045ae79860f4a82","size":1589,"noattachment":false,"key":"/scope-css/-/scope-css-1.0.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/scope-css/download/scope-css-1.0.4.tgz"},"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/scope-css-1.0.4.tgz_1469417085454_0.6778179376851767"},"directories":{},"publish_time":1469417087398,"_hasShrinkwrap":false,"_cnpm_publish_time":1469417087398,"_cnpmcore_publish_time":"2021-12-16T23:07:42.686Z"},"1.0.3":{"name":"scope-css","version":"1.0.3","description":"Scope each css rule with specified selector, so to speak apply nesting to parent","main":"index.js","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"git+https://github.com/dfcreative/scope-css.git"},"keywords":["css","style","insert-css","nesting","scope","nest","parent","selector","sheetify"],"author":{"name":"ΔY","email":"df.creative@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/dfcreative/scope-css/issues"},"homepage":"https://github.com/dfcreative/scope-css#readme","gitHead":"8c7c2ac54fe9739ef0e4ea0d2a1674d2724ede6c","_id":"scope-css@1.0.3","_shasum":"bc5bcf623f07191d583dd6ddcab0cdb3d0d71c88","_from":".","_npmVersion":"3.7.2","_nodeVersion":"6.2.0","_npmUser":{"name":"dfcreative","email":"df.creative@gmail.com"},"maintainers":[{"name":"dfcreative","email":"df.creative@gmail.com"},{"name":"dy","email":"155263213@qq.com"}],"dist":{"shasum":"bc5bcf623f07191d583dd6ddcab0cdb3d0d71c88","size":1525,"noattachment":false,"key":"/scope-css/-/scope-css-1.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/scope-css/download/scope-css-1.0.3.tgz"},"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/scope-css-1.0.3.tgz_1469389893152_0.8446505200117826"},"directories":{},"publish_time":1469389894732,"_hasShrinkwrap":false,"_cnpm_publish_time":1469389894732,"_cnpmcore_publish_time":"2021-12-16T23:07:42.918Z"},"1.0.2":{"name":"scope-css","version":"1.0.2","description":"Scope each css rule with specified selector, so to speak apply nesting to parent","main":"index.js","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"git+https://github.com/dfcreative/scope-css.git"},"keywords":["css","style","insert-css","nesting","scope","nest","parent","selector","sheetify"],"author":{"name":"ΔY","email":"df.creative@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/dfcreative/scope-css/issues"},"homepage":"https://github.com/dfcreative/scope-css#readme","gitHead":"e06c5d6f0624262fefeba8b6a45465e0a8b03f7f","_id":"scope-css@1.0.2","_shasum":"e4570ae493eb195d45041b81880e920a54e0139e","_from":".","_npmVersion":"3.7.2","_nodeVersion":"6.2.0","_npmUser":{"name":"dfcreative","email":"df.creative@gmail.com"},"maintainers":[{"name":"dfcreative","email":"df.creative@gmail.com"},{"name":"dy","email":"155263213@qq.com"}],"dist":{"shasum":"e4570ae493eb195d45041b81880e920a54e0139e","size":1487,"noattachment":false,"key":"/scope-css/-/scope-css-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/scope-css/download/scope-css-1.0.2.tgz"},"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/scope-css-1.0.2.tgz_1468917202423_0.44918987550772727"},"directories":{},"publish_time":1468917204308,"_hasShrinkwrap":false,"_cnpm_publish_time":1468917204308,"_cnpmcore_publish_time":"2021-12-16T23:07:43.154Z"},"1.0.1":{"name":"scope-css","version":"1.0.1","description":"Scope each css rule with specified selector, so to speak apply nesting to parent","main":"index.js","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"git+https://github.com/dfcreative/scope-css.git"},"keywords":["css","style","insert-css","nesting","scope","nest","parent","selector","sheetify"],"author":{"name":"ΔY","email":"df.creative@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/dfcreative/scope-css/issues"},"homepage":"https://github.com/dfcreative/scope-css#readme","gitHead":"13439f2eb4347a0d71262d33f7fa07015e18c451","_id":"scope-css@1.0.1","_shasum":"e86c590489cc0d686fc03866ab555a3bab3ff292","_from":".","_npmVersion":"3.7.2","_nodeVersion":"6.2.0","_npmUser":{"name":"dfcreative","email":"df.creative@gmail.com"},"maintainers":[{"name":"dfcreative","email":"df.creative@gmail.com"},{"name":"dy","email":"155263213@qq.com"}],"dist":{"shasum":"e86c590489cc0d686fc03866ab555a3bab3ff292","size":1482,"noattachment":false,"key":"/scope-css/-/scope-css-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/scope-css/download/scope-css-1.0.1.tgz"},"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/scope-css-1.0.1.tgz_1468916910079_0.5118000062648207"},"directories":{},"publish_time":1468916911807,"_hasShrinkwrap":false,"_cnpm_publish_time":1468916911807,"_cnpmcore_publish_time":"2021-12-16T23:07:43.373Z"},"1.0.0":{"name":"scope-css","version":"1.0.0","description":"Scope each css rule with specified selector, so to speak apply nesting to parent","main":"index.js","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"git+https://github.com/dfcreative/scope-css.git"},"keywords":["css","style","insert-css","nesting","scope","nest","parent","selector"],"author":{"name":"ΔY","email":"df.creative@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/dfcreative/scope-css/issues"},"homepage":"https://github.com/dfcreative/scope-css#readme","gitHead":"ac751b37895f4bbce94d6dd2492bae4021a5a39b","_id":"scope-css@1.0.0","_shasum":"910456b2599a462a8eb68522f639bd2ec53c84b6","_from":".","_npmVersion":"3.7.2","_nodeVersion":"6.2.0","_npmUser":{"name":"dfcreative","email":"df.creative@gmail.com"},"maintainers":[{"name":"dfcreative","email":"df.creative@gmail.com"},{"name":"dy","email":"155263213@qq.com"}],"dist":{"shasum":"910456b2599a462a8eb68522f639bd2ec53c84b6","size":1419,"noattachment":false,"key":"/scope-css/-/scope-css-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/scope-css/download/scope-css-1.0.0.tgz"},"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/scope-css-1.0.0.tgz_1468916201354_0.5651975213550031"},"directories":{},"publish_time":1468916202983,"_hasShrinkwrap":false,"_cnpm_publish_time":1468916202983,"_cnpmcore_publish_time":"2021-12-16T23:07:43.567Z"}},"readme":"# scope-css [![unstable](https://img.shields.io/badge/stability-unstable-green.svg)](http://github.com/badges/stability-badges) [![Build Status](https://img.shields.io/travis/dy/scope-css.svg)](https://travis-ci.org/dy/scope-css)\n\nPrefix or nest each style selector in a css string. Useful to create namespaced css for components, themes, applications, modular css etc. Also it is tiny.\n\n## Usage\n\n[![npm install scope-css](https://nodei.co/npm/scope-css.png?mini=true)](https://npmjs.org/package/scope-css/)\n\n```js\nconst scope = require('scope-css');\n\nscope(`\n.my-component {}\n.my-component-element {}\n`, '.parent');\n\n/*\n`\n.parent .my-component {}\n.parent .my-component-element {}\n`\n*/\n```\n\n## API\n\n## css = scope(css, parent, options?)\n\nReturn css string with each rule prefixed with the parent selector. Note that `parent` selector itself will be ignored. Also each `:host` keyword will be replaced with `parent` value. Example:\n\n```js\nscope(`\n\t.panel {}\n\t:host {}\n\t:host .my-element {}\n\t.panel .my-element {}\n\t.my-element {}\n`, '.panel');\n\n/*\n`\n\t.panel {}\n\t.panel {}\n\t.panel .my-element {}\n\t.panel .my-element {}\n\t.panel .my-element {}\n`\n*/\n```\n\nOptions can scope keyframes via `{ keyframes: bool|prefixStr }` option, eg.\n\n```js\nscope(`\n\t.panel {\n\t\tanimation: infinite loading 4s;\n\t}\n\t@keyframes loading {\n\t\tfrom { top: 0; }\n\t\tto { top: 100px; }\n\t}\n`, '.panel', { keyframes: true })\n\n/*\n`\n.panel {\n\tanimation: infinite panel-loading 4s;\n}\n@keyframes panel-loading {\n\tfrom { top: 0; }\n\tto { top: 100px; }\n`)\n*/\n```\n\n## css = scope.replace(css, 'replacement $1$2')\n\nApply replace to css, where `$1` is matched selectors and `$2` is rules for the selectors. It does not do any self/host detection, so use it for more flexible replacements.\n\n```js\nscope.replace(`\n\t.my-component, .my-other-component {\n\t\tpadding: 0;\n\t}\n`, '$1');\n\n// `.my-component, .my-other-component`\n```\n\n## See also\n\n* [scoped css polyfill](https://github.com/samthor/scoped)\n\n## Credits\n\nBased on [this question](http://stackoverflow.com/questions/12575845/what-is-the-regex-of-a-css-selector).\n","_attachments":{},"homepage":"https://github.com/dy/scope-css#readme","bugs":{"url":"https://github.com/dy/scope-css/issues"},"license":"MIT"}