8000 Remove redundant `.shadow` property as that is defined at the Custom … · trofimander/pyscript@0021ccb · GitHub
[go: up one dir, main page]

Skip to content

Commit 0021ccb

Browse files
Remove redundant .shadow property as that is defined at the Custom Element level. (pyscript#1395)
1 parent 8590c7e commit 0021ccb

File tree

2 files changed

+3
-13
lines changed

2 files changed

+3
-13
lines changed

pyscriptjs/src/components/pywidget.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const logger = getLogger('py-register-widget');
88

99
function createWidget(interpreter: InterpreterClient, name: string, code: string, klass: string) {
1010
class CustomWidget extends HTMLElement {
11-
shadow: ShadowRoot;
1211
wrapper: HTMLElement;
1312

1413
name: string = name;
@@ -20,11 +19,8 @@ function createWidget(interpreter: InterpreterClient, name: string, code: string
2019
constructor() {
2120
super();
2221

23-
// attach shadow so we can preserve the element original innerHtml content
24-
this.shadow = this.attachShadow({ mode: 'open' });
25-
2622
this.wrapper = document.createElement('slot');
27-
this.shadow.appendChild(this.wrapper);
23+
this.attachShadow({ mode: 'open' }).appendChild(this.wrapper);
2824
}
2925

3026
async connectedCallback() {
@@ -45,7 +41,6 @@ function createWidget(interpreter: InterpreterClient, name: string, code: string
4541

4642
export function make_PyWidget(interpreter: InterpreterClient) {
4743
class PyWidget extends HTMLElement {
48-
shadow: ShadowRoot;
4944
name: string;
5045
klass: string;
5146
outputElement: HTMLElement;
@@ -58,11 +53,8 @@ export function make_PyWidget(interpreter: InterpreterClient) {
5853 8000
constructor() {
5954
super();
6055

61-
// attach shadow so we can preserve the element original innerHtml content
62-
this.shadow = this.attachShadow({ mode: 'open' });
63-
6456
this.wrapper = document.createElement('slot');
65-
this.shadow.appendChild(this.wrapper);
57+
this.attachShadow({ mode: 'open' }).appendChild(this.wrapper);
6658

6759
this.addAttributes('src', 'name', 'klass');
6860
}

pyscriptjs/src/plugin.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ type PyElementClass = (htmlElement: HTMLElement) => PyElementInstance;
242242
export function define_custom_element(tag: string, pyElementClass: PyElementClass): any {
243243
logger.info(`creating plugin: ${tag}`);
244244
class ProxyCustomElement extends HTMLElement {
245-
shadow: ShadowRoot;
246245
wrapper: HTMLElement;
247246
pyElementInstance: PyElementInstance;
248247
originalInnerHTML: string;
@@ -251,9 +250,8 @@ export function define_custom_element(tag: string, pyElementClass: PyElementClas
251250
logger.debug(`creating ${tag} plugin instance`);
252251
super();
253252

254-
this.shadow = this.attachShadow({ mode: 'open' });
255253
this.wrapper = document.createElement('slot');
256-
this.shadow.appendChild(this.wrapper);
254+
this.attachShadow({ mode: 'open' }).appendChild(this.wrapper);
257255
this.originalInnerHTML = this.innerHTML;
258256
this.pyElementInstance = pyElementClass(this);
259257
}

0 commit comments

Comments
 (0)
0