Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
css-chain-test
Advanced tools
css-chain hosts ApiChain
and CssChain
JS.
Collection API inherits the element API and Array.
https://unpkg.com/css-chain-test@1.1.9/dist/demo.html
CssChain
returns an Array inherited object which has all methods and properties of its elements.
When method is called, each element would invoke this method and then same CssChain object is returned.
function addTooltip( el ){ /* ...el.title */ }
CssChain( '*[title]' ).forEach( el=>addTooltip( el ) )
.forEach( addTooltip )
.removeAttribute('title');
^^ calls addTiooltip()
twice for each element with title
attribute and then removes this attribute
CssChain( '*[title]', rootEL ).addEventListener( 'click', ev=> alert(ev.target.title) );
^^ adds event listener to all selected elements in rootEl
DOM tree
CssChain( 'a' )
.addEventListener( 'mouseover', ev=> alert(ev.target.classList.add('hovered') ) )
.addEventListener( 'mouseleave', ev=> alert(ev.target.classList.remove('hovered') ) )
.addEventListener( 'focus', ev=> alert(ev.target.classList.add('focused') ) )
.addEventListener( 'mouseleave', ev=> alert(ev.target.classList.remove('focused') ) )
^^ adds multiple event handlers in chainable dot notation.
forEach()
- same as Array.forEach
returns CssChainmap()
- same as Array.map
returns new CssChain with elements from callbackpush(...arr)
- same as Array.push
returns appended CssChainquerySelector(css)
- selects 1st element, returns CssChainquerySelectorAll(css)
- selects all children matching css
, returns CssChain$
- alias to querySelectorAll()
attr(name)
(alias for getAttribute
) returns 1st element attribute value or undefined
for empty collectionattr(name, value)
(alias for setAttribute
) sets elements attribute, returns CssChainprop(name)
returns 1st element property value or undefined
for empty collectionprop(name, value)
sets elements attribute, returns CssChainparent()
- set of immediate parents of current collection, duplications removedparent(css)
- set of parents of current set which
matches
the selector, duplications removedon(eventName, cb)
- alias to addEventListenerremove()
- delete all nodes, returns empty CssChainremove(eventName, cb)
- alias to removeEventListenerWhen property is assigned to collection, this property would be set for all elements in collection. The property get would return property from 1st element.
import { CssChain as $ } from '../src/CssChain.js';
$( 'input' ).value = 'not defined'; // all INPUT elements would have new value set
v = $( 'input' ).prop( value,'not defined' ); // same as ^^
let v = $( 'input' ).value; // variable would receive the 1st INPUT element value
v = $( 'input' ).prop( value ); // same as ^^
$([ {a:1},{a:2} ]).a=1; // all arr elements property `a` set to 1
v = $([ {a:1},{a:2} ]).a; // 1st element property `a` is returned, i.e. 1
$( [ { a:1,f(v){ this.a=v} }, { b:2,f(v){ this.b=v}} ])
.f(3); // method called on each element, result [{a:3},{b:3}]
Could be initiated in same fashion as raw objects. But for performance better to provide the reference object as a second parameter:
class A{ f(){} }
const x = new A(), y = new A();
$( [x,y], A ).f()
for development of css-chain
or css-chain-test
:
git clone https://github.com/sashafirsov/css-chain.git
git clone https://github.com/sashafirsov/css-chain-test.git
cd css-chain
npm i
npm link
cd ../css-chain-test
npm i
npm link css-chain
<script type="module">
import 'css-chain/css-chain-element.js';
</script>
<css-chain></css-chain>
To execute a single test run:
npm run test
To run the tests in interactive watch mode in browser:
npm run test:watch
For most of the tools, the configuration is in the package.json
to minimize the amount of files in your project.
If you customize the configuration a lot, you can consider moving them to individual files.
FAQs
test and demo for css-chain
The npm package css-chain-test receives a total of 128 weekly downloads. As such, css-chain-test popularity was classified as not popular.
We found that css-chain-test 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.
Security News
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.