Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
@stylable/dom-test-kit
Advanced tools
@stylable/dom-test-kit
is comprised of a single class, StylableDOMUtil
, which exposes several DOM related testing utilities.
/* my-component.st.css */
.root {}
.part {
-st-states: loading;
}
/* test.ts */
import { StylableDOMUtil } from '@stylable/dom-test-kit';
import * as stylesheet from './my-component.st.css';
const domUtil = new StylableDOMUtil(stylesheet, document.body);
const partElement = domUtil.select('.part');
if (partElement) {
domUtil.hasStyleState(partElement, 'loading');
}
Note: currently all of the provided utilities support only simplified Stylable selectors, consisting only of
class
andpseudo-class
selectors.
constructor(style: RuntimeStylesheet, root?: Element)
Initialize the StylableDOMUtil
by providing a source stylesheet that would function as the base for all testing utilities. You may pass a DOM root element to serve as the default entry point for the select
methods,
select(selector?: string, element?: Element): Element | null
Select the first element
in the DOM that matches the provided Stylable selector
.
selectAll(selector?: string, element?: Element): Element[] | null
Select all elements
in the DOM that match the provided Stylable selector
.
scopeSelector(selector?: string): string
Transforms a Stylable selector
to its target vanilla CSS.
hasStyleState(element: Element, stateName: string, param: StateValue = true): boolean
Check whether the provided element
has the corresponding state set. This method can also receive a third optional param to validate the state active value.
getStyleState(element: Element, stateName: string): string | null
Get an element
state value if exists, null
if it does not.
Copyright (c) 2017 Wix.com Ltd. All Rights Reserved. Use of this source code is governed by a MIT license.
FAQs
Stylable DOM testing utilities
The npm package @stylable/dom-test-kit receives a total of 890 weekly downloads. As such, @stylable/dom-test-kit popularity was classified as not popular.
We found that @stylable/dom-test-kit demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 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.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.