+ {this.props.customElement.hasAttribute("dev-libs") && (
+
+ )}
{state.showingPopup && (
{
this.forceUpdate();
};
+ atLeastOneOverride = () => {
+ if (this.props.customElement.hasAttribute("dev-libs")) {
+ return overridesBesidesDevLibs();
+ } else {
+ return (
+ Object.keys(window.importMapOverrides.getOverrideMap().imports).length >
+ 0
+ );
+ }
+ };
}
diff --git a/src/ui/list/list.component.js b/src/ui/list/list.component.js
index 3a4b5f5..4758b1a 100644
--- a/src/ui/list/list.component.js
+++ b/src/ui/list/list.component.js
@@ -9,28 +9,7 @@ export default class List extends Component {
searchVal: ""
};
componentDidMount() {
- const notOverriddenMapPromise = Array.prototype.reduce.call(
- document.querySelectorAll(`script[type="${importMapType}"]`),
- (promise, scriptEl) => {
- if (scriptEl.id === "import-map-overrides") {
- return promise;
- } else {
- let nextPromise;
- if (scriptEl.src) {
- nextPromise = fetch(scriptEl.src).then(resp => resp.json());
- } else {
- nextPromise = Promise.resolve(JSON.parse(scriptEl.textContent));
- }
-
- return Promise.all([promise, nextPromise]).then(
- ([originalMap, newMap]) => mergeImportMap(originalMap, newMap)
- );
- }
- },
- Promise.resolve(this.state.notOverriddenMap)
- );
-
- notOverriddenMapPromise.then(notOverriddenMap => {
+ getDefaultMap().then(notOverriddenMap => {
this.setState({ notOverriddenMap });
});
window.addEventListener("import-map-overrides:change", this.doUpdate);
@@ -191,6 +170,29 @@ export default class List extends Component {
};
}
+export function getDefaultMap() {
+ return Array.prototype.reduce.call(
+ document.querySelectorAll(`script[type="${importMapType}"]`),
+ (promise, scriptEl) => {
+ if (scriptEl.id === "import-map-overrides") {
+ return promise;
+ } else {
+ let nextPromise;
+ if (scriptEl.src) {
+ nextPromise = fetch(scriptEl.src).then(resp => resp.json());
+ } else {
+ nextPromise = Promise.resolve(JSON.parse(scriptEl.textContent));
+ }
+
+ return Promise.all([promise, nextPromise]).then(
+ ([originalMap, newMap]) => mergeImportMap(originalMap, newMap)
+ );
+ }
+ },
+ Promise.resolve({ imports: {} })
+ );
+}
+
function mergeImportMap(originalMap, newMap) {
for (let i in newMap.imports) {
originalMap.imports[i] = newMap.imports[i];
diff --git a/test/index.html b/test/index.html
index 528fd0d..d3300d0 100644
--- a/test/index.html
+++ b/test/index.html
@@ -8,13 +8,15 @@
-
+