Skip to content

Instantly share code, notes, and snippets.

@betweenbrain
Created November 19, 2019 21:53
Show Gist options
  • Save betweenbrain/7587859f07d3cc20ed01f44f16b50ab3 to your computer and use it in GitHub Desktop.
Save betweenbrain/7587859f07d3cc20ed01f44f16b50ab3 to your computer and use it in GitHub Desktop.
Vue alter attribute(s) of elements in component

Using querySelectorAll

const inits = this.$el.querySelectorAll('[ga-init]');
inits.forEach(elem => {
  elem.removeAttribute('ga-init');
  elem.removeAttribute('data-ga');
});

Using $children

const children = this.$children;
children.forEach(elem => {
  elem.$el.removeAttribute('ga-init');
  elem.$el.removeAttribute('data-ga');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment