Skip to content

Commit ae1abdd

Browse files
aloopuribsmth
andauthored
Fix beastify code (#22686)
* Fix beastify code * Update code to match source code repo --------- Co-authored-by: Brian Thomas Smith <[email protected]>
1 parent 485e777 commit ae1abdd

File tree

1 file changed

+9
-7
lines changed
  • files/en-us/mozilla/add-ons/webextensions/your_second_webextension

1 file changed

+9
-7
lines changed

files/en-us/mozilla/add-ons/webextensions/your_second_webextension/index.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,7 @@ Note that we include the CSS and JS files from this file, just like a web page.
171171
The CSS fixes the size of the popup, ensures that the three choices fill the space, and gives them some basic styling. It also hides elements with `class="hidden"`: this means that our `<div id="error-content"...` element will be hidden by default.
172172

173173
```css
174-
html,
175-
body {
174+
html, body {
176175
width: 100px;
177176
}
178177

@@ -275,14 +274,16 @@ function listenForClicks() {
275274
* Get the active tab,
276275
* then call "beastify()" or "reset()" as appropriate.
277276
*/
277+
if (e.target.tagName !== "BUTTON" || !e.target.closest("#popup-content")) {
278+
// Ignore when click is not on a button within <div id="popup-content">.
279+
return;
280+
}
278281
if (e.target.type === "reset") {
279-
browser.tabs
280-
.query({ active: true, currentWindow: true })
282+
browser.tabs.query({active: true, currentWindow: true})
281283
.then(reset)
282284
.catch(reportError);
283285
} else {
284-
browser.tabs
285-
.query({ active: true, currentWindow: true })
286+
browser.tabs.query({active: true, currentWindow: true})
286287
.then(beastify)
287288
.catch(reportError);
288289
}
@@ -316,7 +317,8 @@ A common reason the `browser.tabs.executeScript()` call might fail is that you c
316317

317318
If executing the content script is successful, we call `listenForClicks()`. This listens for clicks on the popup.
318319

319-
- If the click was on a button with `class="reset"`, then we call `reset()`.
320+
- If the click was not on a button in the popup, we ignore it and do nothing.
321+
- If the click was on a button with `type="reset"`, then we call `reset()`.
320322
- If the click was on any other button (i.e. the beast buttons), then we call `beastify()`.
321323

322324
The `beastify()` function does three things:

0 commit comments

Comments
 (0)