Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
rework-inherit
Advanced tools
Inherit mixin for rework. Allows you to inherit all the rules associated with a given selector.
var inherit = require('rework-inherit')
var css = rework(inputCSS)
.use(inherit())
.toString()
Option parameters:
propertyRegExp
- Regular expression to match the "inherit" property.
By default, it is /^(inherit|extend)s?$/i
, so it matches "inherit", "inherits", "extend", and "extends".
For example, if you only want to allow the extend
keyword,
set the regular expression to /^extend$/
..gray {
color: gray;
}
.text {
inherit: .gray;
}
yields:
.gray,
.text {
color: gray;
}
Inherit multiple selectors at the same time.
.gray {
color: gray;
}
.black {
color: black;
}
.button {
inherit: .gray, .black;
}
yields:
.gray,
.button {
color: gray;
}
.black,
.button {
color: black;
}
Any selector that includes a %
is considered a placeholder.
Placeholders will not be output in the final CSS.
%gray {
color: gray;
}
.text {
inherit: %gray;
}
yields:
.text {
color: gray;
}
If you inherit a selector, all rules that include that selector will be included as well.
div button span {
color: red;
}
div button {
color: green;
}
button span {
color: pink;
}
.button {
inherit: button;
}
.link {
inherit: div button;
}
yields:
div button span,
div .button span,
.link span {
color: red;
}
div button,
div .button,
.link {
color: green;
}
button span,
.button span {
color: pink;
}
.button {
background-color: gray;
}
.button-large {
inherit: .button;
padding: 10px;
}
.button-large-red {
inherit: .button-large;
color: red;
}
yields:
.button,
.button-large,
.button-large-red {
background-color: gray;
}
.button-large,
.button-large-red {
padding: 10px;
}
.button-large-red {
color: red;
}
Inheriting from inside a media query will create a copy of the declarations.
It will act like a "mixin".
Thus, with %
placeholders, you won't have to use mixins at all.
Each type of media query will need its own declaration,
so there will be some inevitable repetition.
.gray {
color: gray
}
@media (min-width: 320px) {
.button {
inherit: .gray;
}
}
@media (min-width: 320px) {
.link {
inherit: .gray;
}
}
yields:
.gray {
color: gray;
}
@media (min-width: 320px) {
.button,
.link {
color: gray;
}
}
Rework doesn't support nested syntax. However, you can simulate nested syntax with inheritance.
.no-touchevents %link-hover:hover {
text-decoration: underline;
}
a,
button {
inherit: %link-hover;
}
yields:
.no-touchevents a:hover,
.no-touchevents button:hover {
text-decoration: underline;
}
Thus, you have the features of nested syntax without the nesting.
The MIT License (MIT)
Copyright (c) 2013 Jonathan Ong me@jongleberry.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
Inherit rules from other selectors
The npm package rework-inherit receives a total of 2,010 weekly downloads. As such, rework-inherit popularity was classified as popular.
We found that rework-inherit demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 10 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.