@unhead/dom 1.6.0 → 1.6.1

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/dist/index.cjs CHANGED
@@ -17,15 +17,15 @@ async function renderDOMHead(head, options = {}) {
17
17
  const dom = options.document || head.resolvedOptions.document;
18
18
  if (!dom)
19
19
  return;
20
+ const beforeRenderCtx = { shouldRender: head.dirty, tags: [] };
21
+ await head.hooks.callHook("dom:beforeRender", beforeRenderCtx);
22
+ if (!beforeRenderCtx.shouldRender)
23
+ return;
20
24
  const tags = (await head.resolveTags()).map((tag) => ({
21
25
  tag,
22
26
  id: shared.HasElementTags.includes(tag.tag) ? shared.hashTag(tag) : tag.tag,
23
27
  shouldRender: true
24
28
  }));
25
- const beforeRenderCtx = { shouldRender: true, tags };
26
- await head.hooks.callHook("dom:beforeRender", beforeRenderCtx);
27
- if (!beforeRenderCtx.shouldRender)
28
- return;
29
29
  let state = head._dom;
30
30
  if (!state) {
31
31
  state = {
@@ -103,6 +103,7 @@ async function renderDOMHead(head, options = {}) {
103
103
  frag.bodyClose && dom.body.appendChild(frag.bodyClose);
104
104
  Object.values(state.pendingSideEffects).forEach((fn) => fn());
105
105
  head._dom = state;
106
+ head.dirty = false;
106
107
  await head.hooks.callHook("dom:rendered", { renders: tags });
107
108
  }
108
109
 
package/dist/index.mjs CHANGED
@@ -15,15 +15,15 @@ async function renderDOMHead(head, options = {}) {
15
15
  const dom = options.document || head.resolvedOptions.document;
16
16
  if (!dom)
17
17
  return;
18
+ const beforeRenderCtx = { shouldRender: head.dirty, tags: [] };
19
+ await head.hooks.callHook("dom:beforeRender", beforeRenderCtx);
20
+ if (!beforeRenderCtx.shouldRender)
21
+ return;
18
22
  const tags = (await head.resolveTags()).map((tag) => ({
19
23
  tag,
20
24
  id: HasElementTags.includes(tag.tag) ? hashTag(tag) : tag.tag,
21
25
  shouldRender: true
22
26
  }));
23
- const beforeRenderCtx = { shouldRender: true, tags };
24
- await head.hooks.callHook("dom:beforeRender", beforeRenderCtx);
25
- if (!beforeRenderCtx.shouldRender)
26
- return;
27
27
  let state = head._dom;
28
28
  if (!state) {
29
29
  state = {
@@ -101,6 +101,7 @@ async function renderDOMHead(head, options = {}) {
101
101
  frag.bodyClose && dom.body.appendChild(frag.bodyClose);
102
102
  Object.values(state.pendingSideEffects).forEach((fn) => fn());
103
103
  head._dom = state;
104
+ head.dirty = false;
104
105
  await head.hooks.callHook("dom:rendered", { renders: tags });
105
106
  }
106
107
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unhead/dom",
3
3
  "type": "module",
4
- "version": "1.6.0",
4
+ "version": "1.6.1",
5
5
  "author": "Harlan Wilton <harlan@harlanzw.com>",
6
6
  "license": "MIT",
7
7
  "funding": "https://github.com/sponsors/harlan-zw",
@@ -29,8 +29,8 @@
29
29
  "dist"
30
30
  ],
31
31
  "dependencies": {
32
- "@unhead/schema": "1.6.0",
33
- "@unhead/shared": "1.6.0"
32
+ "@unhead/schema": "1.6.1",
33
+ "@unhead/shared": "1.6.1"
34
34
  },
35
35
  "scripts": {
36
36
  "build": "unbuild .",