Skip to content
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.
You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed
pyscriptjs/src/components Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,12 @@ type PyodideInterface = {
27
27
registerJsModule ( name : string , module : object ) : void
28
28
}
29
29
30
+ export function guidGenerator ( ) : string {
31
+ var S4 = function ( ) : string {
32
+ return ( ( ( 1 + Math . random ( ) ) * 0x10000 ) | 0 ) . toString ( 16 ) . substring ( 1 ) ;
33
+ } ;
34
+ return ( S4 ( ) + S4 ( ) + "-" + S4 ( ) + "-" + S4 ( ) + "-" + S4 ( ) + "-" + S4 ( ) + S4 ( ) + S4 ( ) ) ;
35
+ }
30
36
31
37
export class BaseEvalElement extends HTMLElement {
32
38
shadow : ShadowRoot ;
@@ -46,6 +52,8 @@ export class BaseEvalElement extends HTMLElement {
46
52
this . shadow = this . attachShadow ( { mode : 'open' } ) ;
47
53
this . wrapper = document . createElement ( 'slot' ) ;
48
54
this . shadow . appendChild ( this . wrapper ) ;
55
+ if ( ! this . id )
56
+ this . id = this . constructor . name + "-" + guidGenerator ( )
49
57
}
50
58
51
59
addToOutput ( s : string ) {
Original file line number Diff line number Diff line change @@ -144,9 +144,8 @@ export class PyScript extends BaseEvalElement {
144
144
this . id = `pyid-${ Date . now ( ) } `
145
145
}
146
146
this . outputElement = document . createElement ( 'div' ) ;
147
- // this.outputElement.classList.add("output");
148
- this . outputElement . hidden = true ;
149
- this . outputElement . id = this . id + "-" + this . childElementCount ;
147
+ const exec_id = this . getAttribute ( "exec-id" ) ;
148
+ this . outputElement . id = this . id + ( exec_id ? "-" + exec_id : "" ) ;
150
149
151
150
// add the output div id if there's not output pre-defined
152
151
mainDiv . appendChild ( this . outputElement ) ;
You can’t perform that action at this time.
0 commit comments