Skip to content

Commit

Permalink
clear info on new package
Browse files Browse the repository at this point in the history
This avoids seeing the old info for a short time when browsing another
package. This also avoids seeing the old info when a package is not found
(for example 0.18 packages released after 0.19).
  • Loading branch information
rlefevre committed Aug 27, 2019
1 parent 884277d commit 8f5e022
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "Elm Package Info",
"version": "1.7",
"version": "1.8",
"description": "Display additional information for a package on package.elm-lang.org (install command, elm version, license, …)",
"icons": {
"16": "icons/elm-16.png",
Expand Down
13 changes: 10 additions & 3 deletions package.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,18 @@ function updatePackageInfo(pkg, elmJson) {
}
content.appendChild(dependencies);

while (info.firstChild) {
info.removeChild(info.firstChild);
}
removeChildren(info);
info.appendChild(content);
}

function removeChildren(element) {
if (element) {
while (element.firstChild) {
element.removeChild(element.firstChild);
}
}
}

function createCopyToClipboardIcon() {
const svgNS = "http://www.w3.org/2000/svg";
const svg = document.createElementNS(svgNS, "svg");
Expand Down Expand Up @@ -306,6 +312,7 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
}
} else if (packageChanged(pkg, newPkg)) {
resetFooterTranslation();
removeChildren(info);
update(newPkg);
pkg = newPkg;
}
Expand Down

0 comments on commit 8f5e022

Please sign in to comment.