-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexplainer-widget-element.js
More file actions
55 lines (49 loc) · 2.09 KB
/
explainer-widget-element.js
File metadata and controls
55 lines (49 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import {TelepathicElement} from "../telepathic-element/telepathic-element.js";
export default class ExplainerWidgetElement extends TelepathicElement{
static describe(){return `ExplainerWidgetElement provides a widget that shows this source code of any telepathic-element.`};
constructor(){
//super(null,false, true);
//Forward declare template vars
super();
this.source ={
code : "",
jsCount : 30,
lineCount : 30,
description : "",
className : "",
tagName : "",
outerHTML : "",
template : ""
}
this.toExplain = {};
}
async onReady(){
let slot = this.$.querySelector('slot');
this.toExplain = slot.assignedNodes()[0];
console.log("explainer widget explaining: ",this.toExplain);
this.source.tagName = this.toExplain.tagName.toLowerCase();
console.log("source before: ",this.source);
if(!window.customElements.get(this.source.tagName)){
await window.customElements.whenDefined(this.source.tagName);
}
await this.prepSource();
}
async prepSource(){
/*
this.source.code = window.customElements.get(this.source.tagName);
this.source.outerHTML = this.toExplain.outerHTML;
this.source.className = this.toExplain.className;
this.source.templateFileName = toExplain.templateFileName;
this.source.template = this.toExplain.template;
if(!this.source.template || this.source.template == "undefined"){
this.source.template = await this.loadFile(this.source.templateFileName);
}
this.source.jsCount = this.source.code.toString().split(/\r\n|\r|\n/).length + 1;
this.source.lineCount = this.source.template.split(/\r\n|\r|\n/).length + 1;
console.log(this.source.tagName+" is ",this.source.code);
this.source.description = this.source.code.describe();
console.log("source after: ",this.source);
this.removeChild(this.querySelector(this.source.tagName));
*/
}
}