@vueuse/head
Advanced tools
Comparing version 0.5.1 to 0.6.0
@@ -1,2 +0,3 @@ | ||
import { UnwrapRef, App, Ref, DefineComponent, ComponentOptionsMixin, EmitsOptions, VNodeProps, AllowedComponentProps, ComponentCustomProps } from 'vue'; | ||
import * as vue from 'vue'; | ||
import { UnwrapRef, App, Ref } from 'vue'; | ||
@@ -44,4 +45,4 @@ declare type MaybeRef<T> = T | Ref<T>; | ||
declare const renderHeadToString: (head: HeadClient) => HTMLResult; | ||
declare const Head: DefineComponent<{}, () => null, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, EmitsOptions, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<{} & {}>, {}>; | ||
declare const Head: vue.DefineComponent<{}, () => null, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, vue.EmitsOptions, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<{} & {}>, {}>; | ||
export { HTMLResult, Head, HeadAttrs, HeadClient, HeadObject, HeadObjectPlain, HeadTag, createHead, injectHead, renderHeadToString, useHead }; |
@@ -1,3 +0,22 @@ | ||
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/index.ts | ||
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var __defProp = Object.defineProperty; | ||
var __defProps = Object.defineProperties; | ||
var __getOwnPropDescs = Object.getOwnPropertyDescriptors; | ||
var __getOwnPropSymbols = Object.getOwnPropertySymbols; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __propIsEnum = Object.prototype.propertyIsEnumerable; | ||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value; | ||
var __spreadValues = (a, b) => { | ||
for (var prop in b || (b = {})) | ||
if (__hasOwnProp.call(b, prop)) | ||
__defNormalProp(a, prop, b[prop]); | ||
if (__getOwnPropSymbols) | ||
for (var prop of __getOwnPropSymbols(b)) { | ||
if (__propIsEnum.call(b, prop)) | ||
__defNormalProp(a, prop, b[prop]); | ||
} | ||
return a; | ||
}; | ||
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); | ||
// src/index.ts | ||
@@ -8,2 +27,3 @@ | ||
var _vue = require('vue'); | ||
@@ -94,3 +114,3 @@ | ||
} else if (key === "base") { | ||
tags.push({tag: key, props: {key: "default", ...obj[key]}}); | ||
tags.push({tag: key, props: __spreadValues({key: "default"}, obj[key])}); | ||
} else if (acceptFields.includes(key)) { | ||
@@ -168,5 +188,21 @@ const value = obj[key]; | ||
} | ||
if (tag.tag === "meta") { | ||
const key = getTagKey(tag.props); | ||
if (key) { | ||
const elementList = [ | ||
...head.querySelectorAll(`meta[${key.name}="${key.value}"]`) | ||
]; | ||
for (const el of elementList) { | ||
if (!oldElements.includes(el)) { | ||
oldElements.push(el); | ||
} | ||
} | ||
} | ||
} | ||
newElements.push(createElement(tag.tag, tag.props, document)); | ||
} | ||
oldElements.forEach((el) => { | ||
if (el.nextSibling && el.nextSibling.nodeType === Node.TEXT_NODE) { | ||
el.nextSibling.remove(); | ||
} | ||
el.remove(); | ||
@@ -275,12 +311,10 @@ }); | ||
get htmlAttrs() { | ||
return stringifyAttrs({ | ||
...htmlAttrs, | ||
return stringifyAttrs(__spreadProps(__spreadValues({}, htmlAttrs), { | ||
[HEAD_ATTRS_KEY]: Object.keys(htmlAttrs).join(",") | ||
}); | ||
})); | ||
}, | ||
get bodyAttrs() { | ||
return stringifyAttrs({ | ||
...bodyAttrs, | ||
return stringifyAttrs(__spreadProps(__spreadValues({}, bodyAttrs), { | ||
[HEAD_ATTRS_KEY]: Object.keys(bodyAttrs).join(",") | ||
}); | ||
})); | ||
} | ||
@@ -304,6 +338,5 @@ }; | ||
continue; | ||
const props = { | ||
...node.props, | ||
const props = __spreadProps(__spreadValues({}, node.props), { | ||
children: Array.isArray(node.children) ? node.children[0].children : node.children | ||
}; | ||
}); | ||
if (Array.isArray(obj[type])) { | ||
@@ -321,3 +354,3 @@ ; | ||
}; | ||
var Head = _vue.defineComponent.call(void 0, { | ||
var Head = /* @__PURE__ */ _vue.defineComponent.call(void 0, { | ||
name: "Head", | ||
@@ -324,0 +357,0 @@ setup(_, {slots}) { |
{ | ||
"name": "@vueuse/head", | ||
"version": "0.5.1", | ||
"version": "0.6.0", | ||
"license": "MIT", | ||
@@ -26,3 +26,3 @@ "description": "Document head manager for Vue 3. SSR ready.", | ||
"release": "shipjs prepare", | ||
"build": "tsup src/index.ts --format esm,cjs && tsc && dtsup types/index.d.ts", | ||
"build": "tsup src/index.ts --format esm,cjs --dts", | ||
"prepublishOnly": "npm run build", | ||
@@ -68,3 +68,2 @@ "test:e2e": "ava" | ||
"chrome-location": "^1.2.1", | ||
"dtsup": "^1.0.1", | ||
"esbuild-register": "^2.1.0", | ||
@@ -71,0 +70,0 @@ "execa": "^5.0.0", |
# @vueuse/head | ||
[![npm version](https://badgen.net/npm/v/@vueuse/head)](https://npm.im/@vueuse/head) [![npm downloads](https://badgen.net/npm/dm/@vueuse/head)](https://npm.im/@vueuse/head) | ||
Document head manager for Vue 3. | ||
@@ -7,4 +9,2 @@ | ||
[![NPM version](https://img.shields.io/npm/v/@vueuse/head?color=a1b858)](https://www.npmjs.com/package/@vueuse/head) | ||
**💛 Support the ongoing development of this project by [becoming a GitHub Sponsor](https://github.com/sponsors/egoist)**. | ||
@@ -46,3 +46,3 @@ | ||
const siteData = reactive({ | ||
title: `My website` | ||
title: `My website`, | ||
description: `My beautiful website`, | ||
@@ -49,0 +49,0 @@ }) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29387
20
789