Skip to content

Instantly share code, notes, and snippets.

@lukaw3d
Created October 10, 2022 02:22
Show Gist options
  • Select an option

  • Save lukaw3d/3a6a59152e1fb6f58011d748a9c9bea6 to your computer and use it in GitHub Desktop.

Select an option

Save lukaw3d/3a6a59152e1fb6f58011d748a9c9bea6 to your computer and use it in GitHub Desktop.
bookmarklet: add global helper function for finding Vue components
javascript:
/* usage $vm0 = vueFindTag('CardDialog'); */
function vueFindTags(tag = 'ComponentA') {
const flatten = e => [e, ...e.$children.flatMap(child => flatten(child))];
const root = document.querySelector('#app')?.__vue__ || [...document.querySelectorAll('*')].find(e => e.__vue__);
return flatten(root).filter(e => e.$options.name === tag || e.$options._componentTag === tag);
}
function vueFindTag(tag) { return vueFindTags(tag)[0]; }
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment