mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-23 22:00:25 -05:00
Minor refactoring (#557)
* checkpoint: added some text * checkpoint: added setting up the environment, tips for writing good issues * continuing to fill it out * added more detailed description of the process of creating a change and some other cleanup. * added a getting started section and cleaned up the grammar. This ready for the PR now * forgot to add the new section to the TOC * Changes * Minor fixes * Minor fixes * Minor fixes * Minor fixes * Minor fixes * Minor fixes * Fix Co-authored-by: Kevin Goldsmith <kgoldsmith@anaconda.com> Co-authored-by: Matt Kramer <mkramer@anaconda.com>
This commit is contained in:
@@ -81,15 +81,13 @@ export class BaseEvalElement extends HTMLElement {
|
|||||||
const imports: { [key: string]: unknown } = {};
|
const imports: { [key: string]: unknown } = {};
|
||||||
|
|
||||||
for (const node of document.querySelectorAll("script[type='importmap']")) {
|
for (const node of document.querySelectorAll("script[type='importmap']")) {
|
||||||
const importmap = (() => {
|
let importmap;
|
||||||
try {
|
try {
|
||||||
return JSON.parse(node.textContent);
|
importmap = JSON.parse(node.textContent);
|
||||||
} catch {
|
if (importmap?.imports == null) continue;
|
||||||
return null;
|
} catch {
|
||||||
}
|
continue;
|
||||||
})();
|
}
|
||||||
|
|
||||||
if (importmap?.imports == null) continue;
|
|
||||||
|
|
||||||
for (const [name, url] of Object.entries(importmap.imports)) {
|
for (const [name, url] of Object.entries(importmap.imports)) {
|
||||||
if (typeof name != 'string' || typeof url != 'string') continue;
|
if (typeof name != 'string' || typeof url != 'string') continue;
|
||||||
@@ -289,16 +287,15 @@ export class PyWidget extends HTMLElement {
|
|||||||
this.wrapper = document.createElement('slot');
|
this.wrapper = document.createElement('slot');
|
||||||
this.shadow.appendChild(this.wrapper);
|
this.shadow.appendChild(this.wrapper);
|
||||||
|
|
||||||
if (this.hasAttribute('src')) {
|
this.addAttributes('src','name','klass');
|
||||||
this.source = this.getAttribute('src');
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (this.hasAttribute('name')) {
|
addAttributes(...attrs:string[]){
|
||||||
this.name = this.getAttribute('name');
|
for (const each of attrs){
|
||||||
}
|
const property = each === "src" ? "source" : each;
|
||||||
|
if (this.hasAttribute(each)) {
|
||||||
if (this.hasAttribute('klass')) {
|
this[property]=this.getAttribute(each);
|
||||||
this.klass = this.getAttribute('klass');
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user