
Product
Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
inline-styler
Advanced tools
Inline-Styler is a teeny tiny JavaScript library to easily manipulate the style
attribute of an element.
It also works seamlessly with Cheerio on the server-side as well.
.hasStyle(property)
Check whether the element has property
set in its style
attribute.
// <div style="color: red;">…</div>
var styler = new InlineStyler(node.getAttribute('style'))
var hasColor = styler.hasStyle('color') // true
var hasFontSize = styler.hasStyle('font-size') // false
.getStyle(property)
Get value of property
set in its style
attribute or null
.
// <div style="color: red;">…</div>
var styler = new InlineStyler(node.getAttribute('style'))
var color = styler.getStyle('color') // red
var fontSize = styler.getStyle('font-size') // null
.unsetStyle(property)
Unset property
from style
attribute.
var styler = new InlineStyler(node.getAttribute('style'))
styler.unsetStyle('color')
.setStyle(property, value)
Set property
to value
in style
attribute. Override style if it already exists.
var styler = new InlineStyler(node.getAttribute('style'))
// Individual
styler.setStyle('color', 'blue')
styler.setStyle('font-size', '100%')
// Chained
styler
.setStyle('color', 'blue')
.setStyle('font-size', '100%')
.setStyles(object)
Alias for .setStyle(object)
.
var styler = new InlineStyler(node.getAttribute('style'))
styler.setStyles({
'color': 'blue',
'font-size', '100%'
})
.toString()
Returns the string representation to be set as style
attribute.
// <div style="color: red;">…</div>
var styler = new InlineStyler(node.getAttribute('style'))
styler.setStyle('color', 'blue')
node.setAttribute('style', styler.toString())
// <div style="color: blue;">…</div>
var styler = new InlineStyler(node.getAttribute('style'), {
spaceAfterColon: false,
spaceAfterSemiColon: false,
trailingSemiColon: false
})
styler.setStyle('color', 'blue')
styler.setStyle('background', 'red')
node.setAttribute('style', styler.toString())
// <div style="color:blue;background:red">…</div>
npm test
FAQs
A lightweight interface to manipulate the style attribute
We found that inline-styler demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.