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:
ic-768
2022-08-02 15:28:21 +00:00
committed by GitHub
parent cc05a98b0e
commit 844e04ff96

View File

@@ -81,15 +81,13 @@ export class BaseEvalElement extends HTMLElement {
const imports: { [key: string]: unknown } = {};
for (const node of document.querySelectorAll("script[type='importmap']")) {
const importmap = (() => {
try {
return JSON.parse(node.textContent);
} catch {
return null;
}
})();
if (importmap?.imports == null) continue;
let importmap;
try {
importmap = JSON.parse(node.textContent);
if (importmap?.imports == null) continue;
} catch {
continue;
}
for (const [name, url] of Object.entries(importmap.imports)) {
if (typeof name != 'string' || typeof url != 'string') continue;
@@ -289,16 +287,15 @@ export class PyWidget extends HTMLElement {
this.wrapper = document.createElement('slot');
this.shadow.appendChild(this.wrapper);
if (this.hasAttribute('src')) {
this.source = this.getAttribute('src');
}
this.addAttributes('src','name','klass');
}
if (this.hasAttribute('name')) {
this.name = this.getAttribute('name');
}
if (this.hasAttribute('klass')) {
this.klass = this.getAttribute('klass');
addAttributes(...attrs:string[]){
for (const each of attrs){
const property = each === "src" ? "source" : each;
if (this.hasAttribute(each)) {
this[property]=this.getAttribute(each);
}
}
}