@stylable/dom-test-kit
Advanced tools
Comparing version 2.3.0 to 2.3.1-alpha.0
import { RuntimeStylesheet, StateValue } from '@stylable/runtime'; | ||
import { CommonStylesheet } from './legacy-types'; | ||
export interface PartialElement { | ||
@@ -20,2 +21,15 @@ querySelector: Element['querySelector']; | ||
} | ||
export declare class StylableDOMUtilCompat { | ||
private stylesheet; | ||
private root?; | ||
private internal; | ||
constructor(stylesheet: CommonStylesheet, root?: Element | undefined); | ||
select(selector?: string, element?: PartialElement): Element | null; | ||
selectAll(selector?: string, element?: PartialElement): Element[] | null; | ||
scopeSelector(selector?: string): string; | ||
hasStyleState(element: PartialElement, stateName: string, param?: StateValue): boolean; | ||
getStyleState(element: PartialElement, stateName: string): string | boolean | null; | ||
getStateValueFromClassName(cls: string, baseState: string): any; | ||
getBaseStateWithParam(stateName: string): any; | ||
} | ||
//# sourceMappingURL=stylable-dom-util.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var core_1 = require("@stylable/core"); | ||
var legacy_types_1 = require("./legacy-types"); | ||
var stylable_dom_util_legacy_1 = require("./stylable-dom-util-legacy"); | ||
var StylableDOMUtil = /** @class */ (function () { | ||
@@ -99,2 +101,42 @@ function StylableDOMUtil(stylesheet, root) { | ||
exports.StylableDOMUtil = StylableDOMUtil; | ||
var StylableDOMUtilCompat = /** @class */ (function () { | ||
function StylableDOMUtilCompat(stylesheet, root) { | ||
this.stylesheet = stylesheet; | ||
this.root = root; | ||
var mode = legacy_types_1.getStylesheetMode(stylesheet); | ||
if (mode === 'legacy') { | ||
this.internal = new stylable_dom_util_legacy_1.StylableDOMUtilLegacy(this.stylesheet, this.root); | ||
} | ||
else if (mode === 'compat') { | ||
this.internal = new StylableDOMUtil(this.stylesheet.originStylesheet, this.root); | ||
} | ||
else { | ||
this.internal = new StylableDOMUtil(this.stylesheet, this.root); | ||
} | ||
} | ||
StylableDOMUtilCompat.prototype.select = function (selector, element) { | ||
return this.internal.select(selector, element); | ||
}; | ||
StylableDOMUtilCompat.prototype.selectAll = function (selector, element) { | ||
return this.internal.selectAll(selector, element); | ||
}; | ||
StylableDOMUtilCompat.prototype.scopeSelector = function (selector) { | ||
return this.internal.scopeSelector(selector); | ||
}; | ||
StylableDOMUtilCompat.prototype.hasStyleState = function (element, stateName, param) { | ||
if (param === void 0) { param = true; } | ||
return this.internal.hasStyleState(element, stateName, param); | ||
}; | ||
StylableDOMUtilCompat.prototype.getStyleState = function (element, stateName) { | ||
return this.internal.getStyleState(element, stateName); | ||
}; | ||
StylableDOMUtilCompat.prototype.getStateValueFromClassName = function (cls, baseState) { | ||
return this.internal.getStateValueFromClassName(cls, baseState); | ||
}; | ||
StylableDOMUtilCompat.prototype.getBaseStateWithParam = function (stateName) { | ||
return this.internal.getBaseStateWithParam(stateName); | ||
}; | ||
return StylableDOMUtilCompat; | ||
}()); | ||
exports.StylableDOMUtilCompat = StylableDOMUtilCompat; | ||
//# sourceMappingURL=stylable-dom-util.js.map |
{ | ||
"name": "@stylable/dom-test-kit", | ||
"version": "2.3.0", | ||
"version": "2.3.1-alpha.0", | ||
"description": "Stylable DOM testing utilities", | ||
@@ -15,4 +15,4 @@ "main": "./cjs/index.js", | ||
"dependencies": { | ||
"@stylable/core": "^2.3.0", | ||
"@stylable/runtime": "^2.3.0" | ||
"@stylable/core": "^2.3.1-alpha.0", | ||
"@stylable/runtime": "^2.3.1-alpha.0" | ||
}, | ||
@@ -33,3 +33,3 @@ "files": [ | ||
"license": "BSD-3-Clause", | ||
"gitHead": "e727713590e91a31858220a134710cce9e2051b7" | ||
"gitHead": "df3e414745ed1a5d70ce7c8a7f5f27b5ca03a4d3" | ||
} |
@@ -1,3 +0,11 @@ | ||
import { isValidClassName, parseSelector, pseudoStates, stringifySelector, traverseNode } from '@stylable/core'; | ||
import { | ||
isValidClassName, | ||
parseSelector, | ||
pseudoStates, | ||
stringifySelector, | ||
traverseNode | ||
} from '@stylable/core'; | ||
import { RuntimeStylesheet, StateValue } from '@stylable/runtime'; | ||
import { CommonStylesheet, getStylesheetMode } from './legacy-types'; | ||
import { StylableDOMUtilLegacy } from './stylable-dom-util-legacy'; | ||
@@ -106,1 +114,48 @@ export interface PartialElement { | ||
} | ||
export class StylableDOMUtilCompat { | ||
private internal: any; | ||
constructor(private stylesheet: CommonStylesheet, private root?: Element) { | ||
const mode = getStylesheetMode(stylesheet); | ||
if (mode === 'legacy') { | ||
this.internal = new StylableDOMUtilLegacy(this.stylesheet, this.root); | ||
} else if (mode === 'compat') { | ||
this.internal = new StylableDOMUtil( | ||
(this.stylesheet as any).originStylesheet, | ||
this.root | ||
); | ||
} else { | ||
this.internal = new StylableDOMUtil(this.stylesheet as RuntimeStylesheet, this.root); | ||
} | ||
} | ||
public select(selector?: string, element?: PartialElement): Element | null { | ||
return this.internal.select(selector, element); | ||
} | ||
public selectAll(selector?: string, element?: PartialElement): Element[] | null { | ||
return this.internal.selectAll(selector, element); | ||
} | ||
public scopeSelector(selector?: string): string { | ||
return this.internal.scopeSelector(selector); | ||
} | ||
public hasStyleState( | ||
element: PartialElement, | ||
stateName: string, | ||
param: StateValue = true | ||
): boolean { | ||
return this.internal.hasStyleState(element, stateName, param); | ||
} | ||
public getStyleState(element: PartialElement, stateName: string): string | boolean | null { | ||
return this.internal.getStyleState(element, stateName); | ||
} | ||
public getStateValueFromClassName(cls: string, baseState: string) { | ||
return this.internal.getStateValueFromClassName(cls, baseState); | ||
} | ||
public getBaseStateWithParam(stateName: string) { | ||
return this.internal.getBaseStateWithParam(stateName); | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37475
23
527
2