@lynx-js/offscreen-document
Version:
Offscreen Document allows developers to use particular DOM in WebWorker
27 lines • 1.39 kB
JavaScript
// Copyright 2023 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.
import { _attributes, ancestorDocument, } from './OffscreenElement.js';
import { operations } from './OffscreenDocument.js';
import { OperationType } from '../types/ElementOperation.js';
import { uniqueId } from './OffscreenElement.js';
export class OffscreenCSSStyleDeclaration {
/**
* @private
*/
_parent;
constructor(parent) {
this._parent = parent;
}
setProperty(property, value, priority) {
this._parent[ancestorDocument][operations].push(OperationType['StyleDeclarationSetProperty'], this._parent[uniqueId], property, value, priority ?? '');
const currentStyle = this._parent.getAttribute('style') ?? '';
this._parent[_attributes].set('style', currentStyle + `${property}:${value}${priority ? ` !${priority}` : ''};`);
}
removeProperty(property) {
this._parent[ancestorDocument][operations].push(OperationType['StyleDeclarationRemoveProperty'], this._parent[uniqueId], property);
const currentStyle = this._parent.getAttribute('style') ?? '';
this._parent[_attributes].set('style', currentStyle + `${property}:inital;`); // only for SSR
}
}
//# sourceMappingURL=OffscreenCSSStyleDeclaration.js.map