Skip to content

feat: before dom update hookable - #114

Merged
harlan-zw merged 14 commits into
mainfrom
feat/before-dom-update-hook
Oct 1, 2022
Merged

harlan-zw merged 14 commits into
mainfrom
feat/before-dom-update-hook

Conversation

@harlan-zw

@harlan-zw harlan-zw commented Oct 1, 2022 •

Copy link
Copy Markdown
Collaborator

(old PR from fork)

Problem

See nuxt/framework#98, nuxt/framework#75, nuxt/nuxt#14438

Solution

Add a very basic hook system for the DOM update. When a false is returned it won't render.

Example

let pauseDOMUpdates = true
head.hookBeforeDomUpdate.push(() => !pauseDOMUpdates)

nuxtApp.hooks.hookOnce('page:finish', () => {
  pauseDOMUpdates = false
  // start pausing DOM updates when route changes (trigger immediately)
  useRouter().beforeEach(() => {
    pauseDOMUpdates = true
  })

  // watch for new route before unpausing dom updates (triggered after suspense resolved)
  watch(useRoute(), () => {
    pauseDOMUpdates = false
  })
})

@github-actions

github-actions Bot commented Oct 1, 2022

Copy link
Copy Markdown
Contributor

Export Size

@vueuse/head

Name Size Diff
createHead 1.89 KB +44 B (+2.33%) 🔺
Unchanged

@vueuse/head

Name Size Diff
createElement 220 B -
Head 531 B -
injectHead 162 B -
isEqualNode 183 B -
renderHeadToString 741 B -
resolveHeadInput 199 B -
setAttrs 219 B -
sortTags 185 B -
stringifyAttrName 109 B -
stringifyAttrs 260 B -
stringifyAttrValue 101 B -
tagDedupeKey 276 B -
tagToString 424 B -
updateElements 769 B -
useHead 244 B -

@harlan-zw harlan-zw changed the title feat: add hook system for before dom update feat: dom update hookable Oct 1, 2022
@harlan-zw harlan-zw changed the title feat: dom update hookable feat: before dom update hookable Oct 1, 2022
@harlan-zw
harlan-zw merged commit 6d3f3ce into main Oct 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant