Skip to content

Commit 0a9e19d

Browse files
committed
start to document the DOM of py-repl, and rename a variable
1 parent 0c661f5 commit 0a9e19d

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

pyscriptjs/src/components/pyrepl.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,21 @@ export function make_PyRepl(runtime: Runtime) {
2626
};
2727
}
2828

29+
/* High level structore of py-repl DOM, and their JS names
30+
this <py-repl>
31+
.shadow #shadow-root
32+
.mainDiv <div class='py-repl-box'>
33+
<label>...</label>
34+
.editorNode <div class="editor-box"></div>
35+
.outDiv <div class="py-output"></div>
36+
</div>
37+
</py-repl>
38+
*/
2939
class PyRepl extends HTMLElement {
3040
shadow: ShadowRoot;
3141
wrapper: HTMLElement;
3242
code: string;
33-
defaultOutputElement: HTMLElement;
43+
outDiv: HTMLElement;
3444
btnRun: HTMLElement;
3545
editor: EditorView;
3646
editorNode: HTMLElement;
@@ -124,10 +134,10 @@ export function make_PyRepl(runtime: Runtime) {
124134
this.setAttribute('root', this.id);
125135
}
126136

127-
this.defaultOutputElement = document.createElement('div');
128-
this.defaultOutputElement.classList.add('py-output');
129-
this.defaultOutputElement.id = this.id + '-' + this.getAttribute('exec-id');
130-
mainDiv.appendChild(this.defaultOutputElement);
137+
this.outDiv = document.createElement('div');
138+
this.outDiv.classList.add('py-output');
139+
this.outDiv.id = this.id + '-' + this.getAttribute('exec-id');
140+
mainDiv.appendChild(this.outDiv);
131141

132142
this.appendChild(mainDiv);
133143
this.editor.focus();
@@ -164,13 +174,13 @@ export function make_PyRepl(runtime: Runtime) {
164174
const el = document.getElementById(outputID);
165175
if (el === null) {
166176
const err = `py-repl ERROR: cannot find the output element #${outputID} in the DOM`
167-
this.defaultOutputElement.innerText = err;
177+
this.outDiv.innerText = err;
168178
return undefined;
169179
}
170180
return el;
171181
}
172182
else {
173-
return this.defaultOutputElement;
183+
return this.outDiv;
174184
}
175185
}
176186

0 commit comments

Comments
 (0)