@kamen/create-webapp 1.0.23 → 1.0.24
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 +23 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -175,4 +175,27 @@ export function createResourceStyle(code, container = document.head) {
|
|
|
175
175
|
*/
|
|
176
176
|
export function createResourceIframe(code, container = document.body) {
|
|
177
177
|
return createResourceTag(code, 'iframe', 'src', 'text/html', container);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* @param {number} [version=2]
|
|
182
|
+
* @param {Node} [root=document]
|
|
183
|
+
* @param {string} [hook='__VUE_DEVTOOLS_GLOBAL_HOOK__']
|
|
184
|
+
* @returns {Element|string}
|
|
185
|
+
*/
|
|
186
|
+
export function findVue(version = 2, root = document, hook = '__VUE_DEVTOOLS_GLOBAL_HOOK__') {
|
|
187
|
+
let element;
|
|
188
|
+
const property = version === 2 ? '__vue__' : '__vue_app__';
|
|
189
|
+
const treeWalker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT);
|
|
190
|
+
|
|
191
|
+
while (element = treeWalker.nextNode())
|
|
192
|
+
if (property in element) {
|
|
193
|
+
const {[property]: app} = element;
|
|
194
|
+
const {config} = version === 2 ? app.constructor : app;
|
|
195
|
+
config.devtools = true;
|
|
196
|
+
if (hook in window) window[hook].Vue = app.constructor;
|
|
197
|
+
return app;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return 'Vue mountpoint not found';
|
|
178
201
|
}
|