refactor(ShadowCss): add missing types
This commit is contained in:
parent
a6bb84e02b
commit
a121136fae
|
@ -509,7 +509,7 @@ export class CssRule {
|
||||||
constructor(public selector: string, public content: string) {}
|
constructor(public selector: string, public content: string) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function processRules(input: string, ruleCallback: Function): string {
|
export function processRules(input: string, ruleCallback: (rule: CssRule) => CssRule): string {
|
||||||
const inputWithEscapedBlocks = escapeBlocks(input);
|
const inputWithEscapedBlocks = escapeBlocks(input);
|
||||||
let nextBlockIndex = 0;
|
let nextBlockIndex = 0;
|
||||||
return inputWithEscapedBlocks.escapedString.replace(_ruleRe, function(...m: string[]) {
|
return inputWithEscapedBlocks.escapedString.replace(_ruleRe, function(...m: string[]) {
|
||||||
|
|
|
@ -207,8 +207,8 @@ export function main() {
|
||||||
describe('processRules', () => {
|
describe('processRules', () => {
|
||||||
describe('parse rules', () => {
|
describe('parse rules', () => {
|
||||||
function captureRules(input: string): CssRule[] {
|
function captureRules(input: string): CssRule[] {
|
||||||
const result: any[] /** TODO #9100 */ = [];
|
const result: CssRule[] = [];
|
||||||
processRules(input, (cssRule: any /** TODO #9100 */) => {
|
processRules(input, (cssRule) => {
|
||||||
result.push(cssRule);
|
result.push(cssRule);
|
||||||
return cssRule;
|
return cssRule;
|
||||||
});
|
});
|
||||||
|
@ -239,15 +239,15 @@ export function main() {
|
||||||
describe('modify rules', () => {
|
describe('modify rules', () => {
|
||||||
it('should allow to change the selector while preserving whitespaces', () => {
|
it('should allow to change the selector while preserving whitespaces', () => {
|
||||||
expect(processRules(
|
expect(processRules(
|
||||||
'@import a; b {c {d}} e {f}', (cssRule: any /** TODO #9100 */) => new CssRule(
|
'@import a; b {c {d}} e {f}',
|
||||||
cssRule.selector + '2', cssRule.content)))
|
(cssRule: CssRule) => new CssRule(cssRule.selector + '2', cssRule.content)))
|
||||||
.toEqual('@import a2; b2 {c {d}} e2 {f}');
|
.toEqual('@import a2; b2 {c {d}} e2 {f}');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should allow to change the content', () => {
|
it('should allow to change the content', () => {
|
||||||
expect(processRules(
|
expect(processRules(
|
||||||
'a {b}', (cssRule: any /** TODO #9100 */) =>
|
'a {b}',
|
||||||
new CssRule(cssRule.selector, cssRule.content + '2')))
|
(cssRule: CssRule) => new CssRule(cssRule.selector, cssRule.content + '2')))
|
||||||
.toEqual('a {b2}');
|
.toEqual('a {b2}');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue