unhead 0.2.7 → 0.3.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
@@ -311,8 +311,11 @@ const DedupesTagsPlugin = (options) => {
311
311
  if (strategy === "merge") {
312
312
  const oldProps = dupedTag.props;
313
313
  ["class", "style"].forEach((key) => {
314
- if (tag.props[key] && oldProps[key])
314
+ if (tag.props[key] && oldProps[key]) {
315
+ if (key === "style" && !oldProps[key].endsWith(";"))
316
+ oldProps[key] += ";";
315
317
  tag.props[key] = `${oldProps[key]} ${tag.props[key]}`;
318
+ }
316
319
  });
317
320
  deduping[dedupeKey].props = {
318
321
  ...oldProps,
@@ -327,8 +330,6 @@ const DedupesTagsPlugin = (options) => {
327
330
  tag.props[tag._s] = "";
328
331
  }
329
332
  tag._d = dedupeKey;
330
- } else {
331
- tag._p = dupedTag._p;
332
333
  }
333
334
  if (Object.keys(tag.props).length === 0 && !tag.children) {
334
335
  delete deduping[dedupeKey];
@@ -406,18 +407,13 @@ const HydratesStatePlugin = () => {
406
407
  return;
407
408
  if (typeof tag._d === "undefined" && entry._m === "server")
408
409
  return;
409
- const hasChildren = tag.children && tag.children.length > 0;
410
- tag._s = `data-h-${hashCode(tag._d || tag.tag + (hasChildren ? tag.children : JSON.stringify(tag.props)))}`;
410
+ tag._s = `data-h-${hashCode(tag._d || JSON.stringify({ tag: tag.tag, props: tag.props, children: tag.children }))}`;
411
411
  tag.props[tag._s] = "";
412
412
  }
413
413
  }
414
414
  });
415
415
  };
416
416
 
417
- function defineHeadPlugin(plugin) {
418
- return plugin;
419
- }
420
-
421
417
  const PatchDomOnEntryUpdatesPlugin = (options) => {
422
418
  return defineHeadPlugin({
423
419
  hooks: {
@@ -550,12 +546,10 @@ function createHead(options = {}) {
550
546
  plugins.forEach((plugin) => hooks.addHooks(plugin.hooks || {}));
551
547
  const triggerUpdate = () => hooks.callHook("entries:updated", head);
552
548
  const head = {
553
- _removeQueuedSideEffect(key) {
554
- delete _sde[key];
555
- },
556
- _flushQueuedSideEffects() {
557
- Object.values(_sde).forEach((fn) => fn());
549
+ _popSideEffectQueue() {
550
+ const sde = { ..._sde };
558
551
  _sde = {};
552
+ return sde;
559
553
  },
560
554
  headEntries() {
561
555
  return entries;
@@ -616,6 +610,10 @@ function createHead(options = {}) {
616
610
  return head;
617
611
  }
618
612
 
613
+ function defineHeadPlugin(plugin) {
614
+ return plugin;
615
+ }
616
+
619
617
  exports.DedupesTagsPlugin = DedupesTagsPlugin;
620
618
  exports.DeprecatedTagAttrPlugin = DeprecatedTagAttrPlugin;
621
619
  exports.HydratesStatePlugin = HydratesStatePlugin;
package/dist/index.mjs CHANGED
@@ -309,8 +309,11 @@ const DedupesTagsPlugin = (options) => {
309
309
  if (strategy === "merge") {
310
310
  const oldProps = dupedTag.props;
311
311
  ["class", "style"].forEach((key) => {
312
- if (tag.props[key] && oldProps[key])
312
+ if (tag.props[key] && oldProps[key]) {
313
+ if (key === "style" && !oldProps[key].endsWith(";"))
314
+ oldProps[key] += ";";
313
315
  tag.props[key] = `${oldProps[key]} ${tag.props[key]}`;
316
+ }
314
317
  });
315
318
  deduping[dedupeKey].props = {
316
319
  ...oldProps,
@@ -325,8 +328,6 @@ const DedupesTagsPlugin = (options) => {
325
328
  tag.props[tag._s] = "";
326
329
  }
327
330
  tag._d = dedupeKey;
328
- } else {
329
- tag._p = dupedTag._p;
330
331
  }
331
332
  if (Object.keys(tag.props).length === 0 && !tag.children) {
332
333
  delete deduping[dedupeKey];
@@ -404,18 +405,13 @@ const HydratesStatePlugin = () => {
404
405
  return;
405
406
  if (typeof tag._d === "undefined" && entry._m === "server")
406
407
  return;
407
- const hasChildren = tag.children && tag.children.length > 0;
408
- tag._s = `data-h-${hashCode(tag._d || tag.tag + (hasChildren ? tag.children : JSON.stringify(tag.props)))}`;
408
+ tag._s = `data-h-${hashCode(tag._d || JSON.stringify({ tag: tag.tag, props: tag.props, children: tag.children }))}`;
409
409
  tag.props[tag._s] = "";
410
410
  }
411
411
  }
412
412
  });
413
413
  };
414
414
 
415
- function defineHeadPlugin(plugin) {
416
- return plugin;
417
- }
418
-
419
415
  const PatchDomOnEntryUpdatesPlugin = (options) => {
420
416
  return defineHeadPlugin({
421
417
  hooks: {
@@ -548,12 +544,10 @@ function createHead(options = {}) {
548
544
  plugins.forEach((plugin) => hooks.addHooks(plugin.hooks || {}));
549
545
  const triggerUpdate = () => hooks.callHook("entries:updated", head);
550
546
  const head = {
551
- _removeQueuedSideEffect(key) {
552
- delete _sde[key];
553
- },
554
- _flushQueuedSideEffects() {
555
- Object.values(_sde).forEach((fn) => fn());
547
+ _popSideEffectQueue() {
548
+ const sde = { ..._sde };
556
549
  _sde = {};
550
+ return sde;
557
551
  },
558
552
  headEntries() {
559
553
  return entries;
@@ -614,4 +608,8 @@ function createHead(options = {}) {
614
608
  return head;
615
609
  }
616
610
 
611
+ function defineHeadPlugin(plugin) {
612
+ return plugin;
613
+ }
614
+
617
615
  export { DedupesTagsPlugin, DeprecatedTagAttrPlugin, HydratesStatePlugin, PatchDomOnEntryUpdatesPlugin, SortTagsPlugin, TitleTemplatePlugin, activeHead, asArray, createHead, defineHeadPlugin, getActiveHead, normaliseEntryTags, setActiveHead, useBodyAttrs, useHead, useHtmlAttrs, useServerBodyAttrs, useServerHead, useServerHtmlAttrs, useServerTagBase, useServerTagLink, useServerTagMeta, useServerTagMetaFlat, useServerTagNoscript, useServerTagScript, useServerTagStyle, useServerTagTitle, useServerTitleTemplate, useTagBase, useTagLink, useTagMeta, useTagMetaFlat, useTagNoscript, useTagScript, useTagStyle, useTagTitle, useTitleTemplate };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "unhead",
3
3
  "type": "module",
4
- "version": "0.2.7",
4
+ "version": "0.3.1",
5
5
  "packageManager": "pnpm@7.14.0",
6
6
  "author": "Harlan Wilton <harlan@harlanzw.com>",
7
7
  "license": "MIT",
@@ -30,7 +30,8 @@
30
30
  "dist"
31
31
  ],
32
32
  "dependencies": {
33
- "@unhead/schema": "0.2.7",
33
+ "@unhead/dom": "0.3.1",
34
+ "@unhead/schema": "0.3.1",
34
35
  "hookable": "^5.4.1"
35
36
  },
36
37
  "devDependencies": {