-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbe-adoptive.js
40 lines (40 loc) · 1.16 KB
/
be-adoptive.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { BE, propDefaults, propInfo } from 'be-enhanced/BE.js';
import { XE } from 'xtal-element/XE.js';
export class BeAdoptive extends BE {
static get beConfig() {
return {
parse: false,
//primaryProp: 'to'
};
}
async attach(enhancedElement, enhancementInfo) {
await super.attach(enhancedElement, enhancementInfo);
const targetRN = enhancedElement.getRootNode();
const host = targetRN.host;
if (host === undefined)
return;
const rn = host.getRootNode();
const stylesheets = rn.styleSheets;
const targetSheet = new CSSStyleSheet();
for (const stylesheet of stylesheets) {
for (const rule of stylesheet.cssRules) {
targetSheet.insertRule(rule.cssText, targetSheet.cssRules.length);
}
}
targetRN.adoptedStyleSheets = [targetSheet];
}
}
export const tagName = 'be-adoptive';
const xe = new XE({
config: {
tagName,
propDefaults: {
...propDefaults,
},
propInfo: {
...propInfo
},
actions: {}
},
superclass: BeAdoptive
});