You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: files/en-us/mozilla/add-ons/webextensions/content_scripts/cloneinto/index.md
+13-13Lines changed: 13 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ sidebar: addonsidebar
9
9
This function provides a safe way to take an object defined in a privileged scope and create a [structured clone](/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm) of it in a less-privileged scope. It returns a reference to the clone:
10
10
11
11
```js
12
-
var clonedObject =cloneInto(myObject, targetWindow);
@@ -63,7 +63,7 @@ Scripts running in the page can access the object:
63
63
// page script
64
64
button.addEventListener(
65
65
"click",
66
-
function () {
66
+
() => {
67
67
console.log(window.addonScriptObject.greeting); // "hello from your extension"
68
68
},
69
69
false,
@@ -90,18 +90,18 @@ The content script can define an object, clone it, and pass it into this functio
90
90
91
91
```js
92
92
// content script
93
-
var addonScriptObject = { message:"hello from your extension" };
93
+
constaddonScriptObject= { message:"hello from your extension" };
94
94
window.foo(cloneInto(addonScriptObject, window)); // "they said: hello from your extension"
95
95
```
96
96
97
97
### Cloning objects that have functions
98
98
99
-
If the object to clone contains functions, you must pass the `{cloneFunctions:true}` flag, or you get an error. If you do pass this flag, then functions in the object are cloned using the same mechanism used in [`exportFunction`](/en-US/docs/Mozilla/Add-ons/WebExtensions/Content_scripts/exportFunction):
99
+
If the object to clone contains functions, you must pass the `{cloneFunctions:true}` flag, or you get an error. If you do pass this flag, then functions in the object are cloned using the same mechanism used in [`exportFunction`](/en-US/docs/Mozilla/Add-ons/WebExtensions/Content_scripts/exportFunction):
By default, if the object you clone contains objects reflected from C++, such as DOM elements, the cloning operation fails with an error. If you pass the `{wrapReflectors:true}` flag, then the object you clone contains these objects:
127
+
By default, if the object you clone contains objects reflected from C++, such as DOM elements, the cloning operation fails with an error. If you pass the `{wrapReflectors:true}` flag, then the object you clone contains these objects:
Copy file name to clipboardExpand all lines: files/en-us/mozilla/add-ons/webextensions/work_with_the_cookies_api/index.md
+5-6Lines changed: 5 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -128,14 +128,13 @@ The extension's UI uses a toolbar button ({{WebExtAPIRef("browserAction")}}) imp
128
128
To handle the icon buttons the script first gathers all the class names used for the buttons in the HTML file. It then loops through all the buttons assigning them their image and creating an `onclick` listener for each button:
129
129
130
130
```js
131
-
let bgBtns =document.querySelectorAll(".bg-container button");
0 commit comments