head-node-capture 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +19 -0
- package/package.json +15 -0
package/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
;var headNodeCapture=(function(exports){
|
|
2
|
+
exports.capturedNodes = new Array;
|
|
3
|
+
exports.clear = function clear() {
|
|
4
|
+
exports.capturedNodes.length = 0;
|
|
5
|
+
};
|
|
6
|
+
exports.observer = new MutationObserver((mutations) => {
|
|
7
|
+
mutations.forEach(mutation => {
|
|
8
|
+
mutation.addedNodes.forEach(node => {
|
|
9
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
10
|
+
capturedNodes.push(node);
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
exports.disconnect = observer.disconnect.bind(observer);
|
|
16
|
+
exports.connect = observer.observe.bind(observer, document.head, { childList: true, subtree: false });
|
|
17
|
+
exports.connect();
|
|
18
|
+
return exports;
|
|
19
|
+
}(new Object));
|
package/package.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "head-node-capture",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Capture nodes inserted into head and allow users to get them",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"front-end"
|
|
7
|
+
],
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"author": "",
|
|
10
|
+
"type": "commonjs",
|
|
11
|
+
"main": "index.js",
|
|
12
|
+
"scripts": {
|
|
13
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
14
|
+
}
|
|
15
|
+
}
|