nehan
Version:
Html layout engine for paged-media written in Typescript
23 lines • 845 B
JavaScript
import { DynamicStyleContext, CssParser } from "./public-api";
export class DynamicStyle {
constructor(selector, name, callback) {
this.selector = selector;
this.name = name;
this.callback = callback;
}
call(element, parentCtx) {
const callbackCtx = new DynamicStyleContext({
selector: this.selector,
name: this.name,
element: element,
parentContext: parentCtx
});
const callResult = this.callback(callbackCtx) || {};
if (typeof callResult === "string") {
const declrBlock = { [this.name]: callResult };
return CssParser.parseDeclarationBlock(this.selector, declrBlock);
}
return CssParser.parseDeclarationBlock(this.selector, callResult);
}
}
//# sourceMappingURL=dynamic-style.js.map