Skip to content

Instantly share code, notes, and snippets.

@thekhairul
Last active August 31, 2022 16:25
Show Gist options
  • Save thekhairul/89e909a4add5742f0c5cdc61a0a67e79 to your computer and use it in GitHub Desktop.
Save thekhairul/89e909a4add5742f0c5cdc61a0a67e79 to your computer and use it in GitHub Desktop.
Gotchas

css 'fixed' position not relative to viewport but to parent container

  • normally we expect 'fixed' position to be relative to the browser viewport. but for certain curcumstance that might not be the case. when a 'fixed' positioned element has a parent with 'transform' rule applied it becomes relative to that parent

Github pages

  • github pages require a .nojekyll file to be present to properly work with non jekyll project like nuxt

Jest 'Unexpected token <' error for vue components

  • To convert vue components Jest needs vue-jest installed and some extra jest config

Vue $refs.refname returns array

  • Normally vue $refs.refname returns the dom node that has ref="refname" attr. But if this node is inside a v-for then vue $refs return an array instead of the direct dom node. To access the node itself, use this.$refs.refname[0]

Vue 'beforeUnmount' and 'unmounted' hooks are not called

  • Sometimes vue want to reuse the component between updates, so it doesn't remove the instance and doesn't call the unmount hooks. To avoid that, simply bind a unique key attribute to your components. If the key changes, the component is not reused and the full lifecycle methods are called. reference
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment