unhead 0.2.6 → 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];
@@ -377,15 +378,11 @@ const TitleTemplatePlugin = () => {
377
378
  });
378
379
  };
379
380
 
380
- function defineHeadPlugin(plugin) {
381
- return plugin;
382
- }
383
-
384
381
  const DeprecatedTagAttrPlugin = () => {
385
382
  return defineHeadPlugin({
386
383
  hooks: {
387
384
  "tag:normalise": function({ tag }) {
388
- if (tag.props.body) {
385
+ if (typeof tag.props.body !== "undefined") {
389
386
  tag.tagPosition = "bodyClose";
390
387
  delete tag.props.body;
391
388
  }
@@ -410,8 +407,7 @@ const HydratesStatePlugin = () => {
410
407
  return;
411
408
  if (typeof tag._d === "undefined" && entry._m === "server")
412
409
  return;
413
- const hasChildren = tag.children && tag.children.length > 0;
414
- 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 }))}`;
415
411
  tag.props[tag._s] = "";
416
412
  }
417
413
  }
@@ -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];
@@ -375,15 +376,11 @@ const TitleTemplatePlugin = () => {
375
376
  });
376
377
  };
377
378
 
378
- function defineHeadPlugin(plugin) {
379
- return plugin;
380
- }
381
-
382
379
  const DeprecatedTagAttrPlugin = () => {
383
380
  return defineHeadPlugin({
384
381
  hooks: {
385
382
  "tag:normalise": function({ tag }) {
386
- if (tag.props.body) {
383
+ if (typeof tag.props.body !== "undefined") {
387
384
  tag.tagPosition = "bodyClose";
388
385
  delete tag.props.body;
389
386
  }
@@ -408,8 +405,7 @@ const HydratesStatePlugin = () => {
408
405
  return;
409
406
  if (typeof tag._d === "undefined" && entry._m === "server")
410
407
  return;
411
- const hasChildren = tag.children && tag.children.length > 0;
412
- 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 }))}`;
413
409
  tag.props[tag._s] = "";
414
410
  }
415
411
  }
@@ -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.6",
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.6",
33
+ "@unhead/dom": "0.3.1",
34
+ "@unhead/schema": "0.3.1",
34
35
  "hookable": "^5.4.1"
35
36
  },
36
37
  "devDependencies": {