From 4ba90a925041e552ffbf3d13179c43d9e870a2b4 Mon Sep 17 00:00:00 2001 From: Fabio Pliger Date: Mon, 18 Apr 2022 18:56:49 -0500 Subject: [PATCH] rename target attribute to output --- pyscriptjs/examples/repl2.html | 2 +- pyscriptjs/src/components/base.ts | 2 +- pyscriptjs/src/components/pyrepl.ts | 12 ++++++------ pyscriptjs/src/components/pyscript.ts | 16 ++++++++-------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/pyscriptjs/examples/repl2.html b/pyscriptjs/examples/repl2.html index 53099a2..614f057 100644 --- a/pyscriptjs/examples/repl2.html +++ b/pyscriptjs/examples/repl2.html @@ -21,7 +21,7 @@ - +
diff --git a/pyscriptjs/src/components/base.ts b/pyscriptjs/src/components/base.ts index 1db90e2..129191e 100644 --- a/pyscriptjs/src/components/base.ts +++ b/pyscriptjs/src/components/base.ts @@ -132,7 +132,7 @@ export class BaseEvalElement extends HTMLElement { // @ts-ignore out.write.callKwargs(output, { append : true}); - if (!this.hasAttribute('target')) { + if (!this.hasAttribute('output')) { this.outputElement.hidden = false; } } diff --git a/pyscriptjs/src/components/pyrepl.ts b/pyscriptjs/src/components/pyrepl.ts index b6a918b..6ed79b1 100644 --- a/pyscriptjs/src/components/pyrepl.ts +++ b/pyscriptjs/src/components/pyrepl.ts @@ -134,7 +134,7 @@ export class PyRepl extends BaseEvalElement { currentComponentDetails.set([ {key: "auto-generate", value: true}, - {key:"target", value: "default"}, + {key:"output", value: "default"}, {key: "source", value: "self"}, {key: "output-mode", value: "clear"} ]) @@ -160,8 +160,8 @@ export class PyRepl extends BaseEvalElement { this.setAttribute("root", this.id); } - if (this.hasAttribute('target')) { - this.outputElement = document.getElementById(this.getAttribute('target')); + if (this.hasAttribute('output')) { + this.outputElement = document.getElementById(this.getAttribute('output')); // in this case, the default output-mode is append, if hasn't been specified if (!this.hasAttribute('output-mode')) { @@ -174,7 +174,7 @@ export class PyRepl extends BaseEvalElement { this.outputElement.hidden = true; this.outputElement.id = this.id + "-" + this.getAttribute("exec-id"); - // add the output div id there's not target + // add the output div id if there's not output pre-defined mainDiv.appendChild(this.outputElement); } @@ -195,8 +195,8 @@ export class PyRepl extends BaseEvalElement { newPyRepl.setAttribute('root', this.getAttribute('root')); newPyRepl.id = this.getAttribute('root') + "-" + nextExecId.toString(); newPyRepl.setAttribute('auto-generate', null); - if (this.hasAttribute('target')){ - newPyRepl.setAttribute('target', this.getAttribute('target')); + if (this.hasAttribute('output')){ + newPyRepl.setAttribute('output', this.getAttribute('output')); } newPyRepl.setAttribute('exec-id', nextExecId.toString()); diff --git a/pyscriptjs/src/components/pyscript.ts b/pyscriptjs/src/components/pyscript.ts index 60cc86e..f8e8951 100644 --- a/pyscriptjs/src/components/pyscript.ts +++ b/pyscriptjs/src/components/pyscript.ts @@ -56,10 +56,10 @@ type PyodideInterface = { class Script { source: string; state: string; - target: string; + output: string; - constructor(source: string, target: string) { - this.target = target; + constructor(source: string, output: string) { + this.output = output; this.source = source; this.state = 'waiting'; } @@ -78,7 +78,7 @@ class Script { output = pyodide.runPython(this.source); } - if (this.target){ + if (this.output){ // this.editorOut.innerHTML = s; } // if (output !== undefined){ @@ -161,7 +161,7 @@ export class PyScript extends BaseEvalElement { currentComponentDetails.set([ {key: "auto-generate", value: true}, - {key:"target", value: "default"}, + {key:"output", value: "default"}, {key: "source", value: "self"} ]) } @@ -172,15 +172,15 @@ export class PyScript extends BaseEvalElement { mainDiv.appendChild(eDiv); - if (this.hasAttribute('target')) { - this.outputElement = document.getElementById(this.getAttribute('target')); + if (this.hasAttribute('output')) { + this.outputElement = document.getElementById(this.getAttribute('output')); }else{ // Editor Output Div this.outputElement = document.createElement('div'); this.outputElement.classList.add("output"); this.outputElement.hidden = true; - // add the output div id there's not target + // add the output div id there's no output element mainDiv.appendChild(this.outputElement); }