mirror of
https://github.com/pyscript/pyscript.git
synced 2022-05-01 19:47:48 +03:00
move check id out of constructor
This commit is contained in:
@@ -45,8 +45,6 @@ export class BaseEvalElement extends HTMLElement {
|
||||
this.shadow = this.attachShadow({ mode: 'open'});
|
||||
this.wrapper = document.createElement('slot');
|
||||
this.shadow.appendChild(this.wrapper);
|
||||
if (!this.id)
|
||||
this.id = this.constructor.name+"-"+guidGenerator()
|
||||
}
|
||||
|
||||
addToOutput(s: string) {
|
||||
@@ -58,6 +56,11 @@ export class BaseEvalElement extends HTMLElement {
|
||||
|
||||
}
|
||||
|
||||
checkId(){
|
||||
if (!this.id)
|
||||
this.id = this.constructor.name+"-"+guidGenerator();
|
||||
}
|
||||
|
||||
getSourceFromElement(): string{
|
||||
return "";
|
||||
}
|
||||
@@ -165,6 +168,8 @@ export class BaseEvalElement extends HTMLElement {
|
||||
} // end eval
|
||||
}
|
||||
|
||||
|
||||
|
||||
function createWidget(name: string, code: string, klass: string){
|
||||
|
||||
class CustomWidget extends HTMLElement{
|
||||
|
||||
@@ -59,6 +59,7 @@ export class PyRepl extends BaseEvalElement {
|
||||
|
||||
|
||||
connectedCallback() {
|
||||
this.checkId()
|
||||
this.code = this.innerHTML;
|
||||
this.innerHTML = '';
|
||||
|
||||
|
||||
@@ -98,6 +98,7 @@ export class PyScript extends BaseEvalElement {
|
||||
}
|
||||
|
||||
connectedCallback() {
|
||||
this.checkId()
|
||||
this.code = this.innerHTML;
|
||||
this.innerHTML = '';
|
||||
let startState = EditorState.create({
|
||||
|
||||
Reference in New Issue
Block a user