Skip to content

Commit b802766

Browse files
committed
chore(release): 3.0.0-alpha.7
1 parent c492437 commit b802766

10 files changed

+143
-59
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
## [3.0.0-alpha.7](https://github.com/nuxt/vue-meta/compare/v3.0.0-alpha.6...v3.0.0-alpha.7) (2021-05-23)
6+
7+
8+
### Bug Fixes
9+
10+
* check if DOM is still loading before cleanup ([1785d4f](https://github.com/nuxt/vue-meta/commit/1785d4fef6b2c2adaa645e44419c3da883863562))
11+
* export ssr type declarion into ssr folder ([01e4aed](https://github.com/nuxt/vue-meta/commit/01e4aed34034984e5a523d77db9bd79e66418678))
12+
* get keyAttribute _either_ from section or tag config ([e551fe4](https://github.com/nuxt/vue-meta/commit/e551fe46fe6f81726f6f6ce9734aedccdc0753df))
13+
* get keyAttribute either from section or tag config ([3b3d3f4](https://github.com/nuxt/vue-meta/commit/3b3d3f4397eb83003c5d1dd69ec862b39c9fbf37))
14+
* SSR active, dont use global active var due to runInNewContext: false ([#668](https://github.com/nuxt/vue-meta/issues/668)) ([6593e92](https://github.com/nuxt/vue-meta/commit/6593e9272dea7585cb72b925beafad2020c623db))
15+
* use document.title to update title on the client ([88d57e7](https://github.com/nuxt/vue-meta/commit/88d57e71993bab8866cc9de22534b39ca01dbf33))
16+
517
## [3.0.0-alpha.6](https://github.com/nuxt/vue-meta/compare/v3.0.0-alpha.5...v3.0.0-alpha.6) (2021-05-17)
618

719

dist/vue-meta.cjs.js

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* vue-meta v3.0.0-alpha.6
2+
* vue-meta v3.0.0-alpha.7
33
* (c) 2021
44
* - Pim (@pimlie)
55
* - All the amazing contributors
@@ -518,6 +518,7 @@ function renderGroup(context, key, data, config) {
518518
}
519519
return renderTag(context, key, data[childKey], config, groupConfig);
520520
})
521+
.filter(Boolean)
521522
.flat();
522523
}
523524
function renderTag(context, key, data, config = {}, groupConfig) {
@@ -529,6 +530,7 @@ function renderTag(context, key, data, config = {}, groupConfig) {
529530
.map((child) => {
530531
return renderTag(context, key, child, config, groupConfig);
531532
})
533+
.filter(Boolean)
532534
.flat();
533535
}
534536
const { tag = config.tag || key } = data;
@@ -545,7 +547,7 @@ function renderTag(context, key, data, config = {}, groupConfig) {
545547
if (isArray(data)) {
546548
return data.map(({ vnode }) => vnode);
547549
}
548-
return data.vnode;
550+
return data && data.vnode;
549551
});
550552
}
551553
else {
@@ -594,8 +596,9 @@ function renderTag(context, key, data, config = {}, groupConfig) {
594596
content = getSlotContent(context, slotName, content, data);
595597
}
596598
else {
597-
const { nameless, keyAttribute } = config;
599+
const { nameless } = config;
598600
if (!nameless) {
601+
const keyAttribute = config.keyAttribute || getTagConfig('keyAttribute');
599602
if (keyAttribute) {
600603
attributes[keyAttribute] = fullName;
601604
}
@@ -607,6 +610,10 @@ function renderTag(context, key, data, config = {}, groupConfig) {
607610
const finalTag = groupConfig && groupConfig.tagNamespace
608611
? `${groupConfig.tagNamespace}:${tag}`
609612
: tag;
613+
if (finalTag === 'title' && !context.isSSR) {
614+
document.title = content;
615+
return;
616+
}
610617
// console.info('FINAL TAG', finalTag)
611618
// console.log(' ATTRIBUTES', attributes)
612619
// console.log(' CONTENT', content)
@@ -766,7 +773,6 @@ const MetainfoImpl = vue.defineComponent({
766773
const Metainfo = MetainfoImpl;
767774

768775
const ssrAttribute = 'data-vm-ssr';
769-
const active = vue.reactive({});
770776
function addVnode(isSSR, teleports, to, vnodes) {
771777
const nodes = (isArray(vnodes) ? vnodes : [vnodes]);
772778
if (!isSSR) {
@@ -806,7 +812,7 @@ class MetaManager {
806812
install(app) {
807813
app.component('Metainfo', Metainfo);
808814
app.config.globalProperties.$metaManager = this;
809-
app.provide(metaActiveKey, active);
815+
app.provide(metaActiveKey, this.target.context.active);
810816
}
811817
addMeta(metadata, vm) {
812818
if (!vm) {
@@ -865,20 +871,27 @@ class MetaManager {
865871
}
866872
}
867873
render({ slots } = {}) {
874+
const active = this.target.context.active;
868875
// TODO: clean this method
869876
const { isSSR } = this;
870877
// cleanup ssr tags if not yet done
871878
if (!isSSR && !this.ssrCleanedUp) {
872879
this.ssrCleanedUp = true;
873-
// Listen for DOM loaded because tags in the body couldnt
874-
// have loaded yet once the manager does it first render
875-
// (preferable there should only be one meta render on hydration)
876-
window.addEventListener('DOMContentLoaded', () => {
880+
const cleanUpSSR = () => {
877881
const ssrTags = document.querySelectorAll(`[${ssrAttribute}]`);
878882
if (ssrTags && ssrTags.length) {
879883
ssrTags.forEach(el => el.parentNode && el.parentNode.removeChild(el));
880884
}
881-
}, { once: true });
885+
};
886+
if (document.readyState === 'loading') {
887+
// Listen for DOM loaded because tags in the body couldnt
888+
// have loaded yet once the manager does it first render
889+
// (preferable there should only be one meta render on hydration)
890+
window.addEventListener('DOMContentLoaded', cleanUpSSR, { once: true });
891+
}
892+
else {
893+
cleanUpSSR();
894+
}
882895
}
883896
const teleports = {};
884897
for (const key in active) {
@@ -927,6 +940,7 @@ MetaManager.create = (isSSR, config, resolver) => {
927940
}
928941
return resolver.resolve(options, contexts, active, key, pathSegments);
929942
};
943+
const active = vue.reactive({});
930944
const mergedObject = createMergedObject(resolve, active);
931945
// TODO: validate resolver
932946
const manager = new MetaManager(isSSR, config, mergedObject, resolver);

dist/vue-meta.cjs.prod.js

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* vue-meta v3.0.0-alpha.6
2+
* vue-meta v3.0.0-alpha.7
33
* (c) 2021
44
* - Pim (@pimlie)
55
* - All the amazing contributors
@@ -507,6 +507,7 @@ function renderGroup(context, key, data, config) {
507507
}
508508
return renderTag(context, key, data[childKey], config, groupConfig);
509509
})
510+
.filter(Boolean)
510511
.flat();
511512
}
512513
function renderTag(context, key, data, config = {}, groupConfig) {
@@ -518,6 +519,7 @@ function renderTag(context, key, data, config = {}, groupConfig) {
518519
.map((child) => {
519520
return renderTag(context, key, child, config, groupConfig);
520521
})
522+
.filter(Boolean)
521523
.flat();
522524
}
523525
const { tag = config.tag || key } = data;
@@ -534,7 +536,7 @@ function renderTag(context, key, data, config = {}, groupConfig) {
534536
if (isArray(data)) {
535537
return data.map(({ vnode }) => vnode);
536538
}
537-
return data.vnode;
539+
return data && data.vnode;
538540
});
539541
}
540542
else {
@@ -583,8 +585,9 @@ function renderTag(context, key, data, config = {}, groupConfig) {
583585
content = getSlotContent(context, slotName, content, data);
584586
}
585587
else {
586-
const { nameless, keyAttribute } = config;
588+
const { nameless } = config;
587589
if (!nameless) {
590+
const keyAttribute = config.keyAttribute || getTagConfig('keyAttribute');
588591
if (keyAttribute) {
589592
attributes[keyAttribute] = fullName;
590593
}
@@ -596,6 +599,10 @@ function renderTag(context, key, data, config = {}, groupConfig) {
596599
const finalTag = groupConfig && groupConfig.tagNamespace
597600
? `${groupConfig.tagNamespace}:${tag}`
598601
: tag;
602+
if (finalTag === 'title' && !context.isSSR) {
603+
document.title = content;
604+
return;
605+
}
599606
// console.info('FINAL TAG', finalTag)
600607
// console.log(' ATTRIBUTES', attributes)
601608
// console.log(' CONTENT', content)
@@ -746,7 +753,6 @@ const MetainfoImpl = vue.defineComponent({
746753
const Metainfo = MetainfoImpl;
747754

748755
const ssrAttribute = 'data-vm-ssr';
749-
const active = vue.reactive({});
750756
function addVnode(isSSR, teleports, to, vnodes) {
751757
const nodes = (isArray(vnodes) ? vnodes : [vnodes]);
752758
if (!isSSR) {
@@ -786,7 +792,7 @@ class MetaManager {
786792
install(app) {
787793
app.component('Metainfo', Metainfo);
788794
app.config.globalProperties.$metaManager = this;
789-
app.provide(metaActiveKey, active);
795+
app.provide(metaActiveKey, this.target.context.active);
790796
}
791797
addMeta(metadata, vm) {
792798
if (!vm) {
@@ -845,20 +851,27 @@ class MetaManager {
845851
}
846852
}
847853
render({ slots } = {}) {
854+
const active = this.target.context.active;
848855
// TODO: clean this method
849856
const { isSSR } = this;
850857
// cleanup ssr tags if not yet done
851858
if (!isSSR && !this.ssrCleanedUp) {
852859
this.ssrCleanedUp = true;
853-
// Listen for DOM loaded because tags in the body couldnt
854-
// have loaded yet once the manager does it first render
855-
// (preferable there should only be one meta render on hydration)
856-
window.addEventListener('DOMContentLoaded', () => {
860+
const cleanUpSSR = () => {
857861
const ssrTags = document.querySelectorAll(`[${ssrAttribute}]`);
858862
if (ssrTags && ssrTags.length) {
859863
ssrTags.forEach(el => el.parentNode && el.parentNode.removeChild(el));
860864
}
861-
}, { once: true });
865+
};
866+
if (document.readyState === 'loading') {
867+
// Listen for DOM loaded because tags in the body couldnt
868+
// have loaded yet once the manager does it first render
869+
// (preferable there should only be one meta render on hydration)
870+
window.addEventListener('DOMContentLoaded', cleanUpSSR, { once: true });
871+
}
872+
else {
873+
cleanUpSSR();
874+
}
862875
}
863876
const teleports = {};
864877
for (const key in active) {
@@ -907,6 +920,7 @@ MetaManager.create = (isSSR, config, resolver) => {
907920
}
908921
return resolver.resolve(options, contexts, active, key, pathSegments);
909922
};
923+
const active = vue.reactive({});
910924
const mergedObject = createMergedObject(resolve, active);
911925
// TODO: validate resolver
912926
const manager = new MetaManager(isSSR, config, mergedObject, resolver);

dist/vue-meta.d.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* vue-meta v3.0.0-alpha.6
2+
* vue-meta v3.0.0-alpha.7
33
* (c) 2021
44
* - Pim (@pimlie)
55
* - All the amazing contributors
@@ -96,6 +96,8 @@ declare type MetaTagsConfig = {
9696
};
9797

9898
declare type Modify<T, R> = Omit<T, keyof R> & R;
99+
declare type Truthy<T> = T extends undefined | void | null | false | 0 | '' ? never : T;
100+
declare type ExcludesFalsy = <T>(x: T) => x is Truthy<T>;
99101
declare type TODO = any;
100102
/**
101103
* Proxied meta source for tracking changes and updating the active meta daa
@@ -214,4 +216,4 @@ declare function getCurrentManager(vm?: ComponentInternalInstance): MetaManager
214216
declare function useMeta(source: MetaSource, manager?: MetaManager): MetaProxy;
215217
declare function useActiveMeta(): MetaActive;
216218

217-
export { MetaActive, MetaConfig, MetaConfigSection, MetaConfigSectionAttribute, MetaConfigSectionGroup, MetaConfigSectionKey, MetaConfigSectionTag, MetaGroupConfig, MetaGuardRemoved, MetaGuards, MetaProxy, MetaRenderContext, MetaRendered, MetaRenderedNode, MetaResolveContext, MetaResolveSetup, MetaResolver, MetaResolverSetup, MetaSource, MetaSourceProxy, MetaTagConfig, MetaTagConfigKey, MetaTagName, MetaTagsConfig, MetaTeleports, Modify, SlotScopeProperties, TODO, createMetaManager, deepest_d as deepestResolver, defaultConfig, getCurrentManager, resolveOption, useActiveMeta, useMeta };
219+
export { ExcludesFalsy, MetaActive, MetaConfig, MetaConfigSection, MetaConfigSectionAttribute, MetaConfigSectionGroup, MetaConfigSectionKey, MetaConfigSectionTag, MetaGroupConfig, MetaGuardRemoved, MetaGuards, MetaProxy, MetaRenderContext, MetaRendered, MetaRenderedNode, MetaResolveContext, MetaResolveSetup, MetaResolver, MetaResolverSetup, MetaSource, MetaSourceProxy, MetaTagConfig, MetaTagConfigKey, MetaTagName, MetaTagsConfig, MetaTeleports, Modify, SlotScopeProperties, TODO, Truthy, createMetaManager, deepest_d as deepestResolver, defaultConfig, getCurrentManager, resolveOption, useActiveMeta, useMeta };

dist/vue-meta.esm-browser.js

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/**
2-
* vue-meta v3.0.0-alpha.6
2+
* vue-meta v3.0.0-alpha.7
33
* (c) 2021
44
* - Pim (@pimlie)
55
* - All the amazing contributors
66
* @license MIT
77
*/
88

9-
import { markRaw, h, getCurrentInstance, isProxy, watch, inject, defineComponent, reactive, onUnmounted, Teleport, Comment } from 'vue';
9+
import { markRaw, h, getCurrentInstance, isProxy, watch, inject, defineComponent, onUnmounted, Teleport, reactive, Comment } from 'vue';
1010

1111
const resolveOption = (predicament, initialValue) => (options, contexts) => {
1212
let resolvedIndex = -1;
@@ -514,6 +514,7 @@ function renderGroup(context, key, data, config) {
514514
}
515515
return renderTag(context, key, data[childKey], config, groupConfig);
516516
})
517+
.filter(Boolean)
517518
.flat();
518519
}
519520
function renderTag(context, key, data, config = {}, groupConfig) {
@@ -525,6 +526,7 @@ function renderTag(context, key, data, config = {}, groupConfig) {
525526
.map((child) => {
526527
return renderTag(context, key, child, config, groupConfig);
527528
})
529+
.filter(Boolean)
528530
.flat();
529531
}
530532
const { tag = config.tag || key } = data;
@@ -541,7 +543,7 @@ function renderTag(context, key, data, config = {}, groupConfig) {
541543
if (isArray(data)) {
542544
return data.map(({ vnode }) => vnode);
543545
}
544-
return data.vnode;
546+
return data && data.vnode;
545547
});
546548
}
547549
else {
@@ -590,8 +592,9 @@ function renderTag(context, key, data, config = {}, groupConfig) {
590592
content = getSlotContent(context, slotName, content, data);
591593
}
592594
else {
593-
const { nameless, keyAttribute } = config;
595+
const { nameless } = config;
594596
if (!nameless) {
597+
const keyAttribute = config.keyAttribute || getTagConfig('keyAttribute');
595598
if (keyAttribute) {
596599
attributes[keyAttribute] = fullName;
597600
}
@@ -603,6 +606,10 @@ function renderTag(context, key, data, config = {}, groupConfig) {
603606
const finalTag = groupConfig && groupConfig.tagNamespace
604607
? `${groupConfig.tagNamespace}:${tag}`
605608
: tag;
609+
if (finalTag === 'title' && !context.isSSR) {
610+
document.title = content;
611+
return;
612+
}
606613
// console.info('FINAL TAG', finalTag)
607614
// console.log(' ATTRIBUTES', attributes)
608615
// console.log(' CONTENT', content)
@@ -762,7 +769,6 @@ const MetainfoImpl = defineComponent({
762769
const Metainfo = MetainfoImpl;
763770

764771
const ssrAttribute = 'data-vm-ssr';
765-
const active = reactive({});
766772
function addVnode(isSSR, teleports, to, vnodes) {
767773
const nodes = (isArray(vnodes) ? vnodes : [vnodes]);
768774
if (!isSSR) {
@@ -802,7 +808,7 @@ class MetaManager {
802808
install(app) {
803809
app.component('Metainfo', Metainfo);
804810
app.config.globalProperties.$metaManager = this;
805-
app.provide(metaActiveKey, active);
811+
app.provide(metaActiveKey, this.target.context.active);
806812
}
807813
addMeta(metadata, vm) {
808814
if (!vm) {
@@ -861,20 +867,27 @@ class MetaManager {
861867
}
862868
}
863869
render({ slots } = {}) {
870+
const active = this.target.context.active;
864871
// TODO: clean this method
865872
const { isSSR } = this;
866873
// cleanup ssr tags if not yet done
867874
if (!isSSR && !this.ssrCleanedUp) {
868875
this.ssrCleanedUp = true;
869-
// Listen for DOM loaded because tags in the body couldnt
870-
// have loaded yet once the manager does it first render
871-
// (preferable there should only be one meta render on hydration)
872-
window.addEventListener('DOMContentLoaded', () => {
876+
const cleanUpSSR = () => {
873877
const ssrTags = document.querySelectorAll(`[${ssrAttribute}]`);
874878
if (ssrTags && ssrTags.length) {
875879
ssrTags.forEach(el => el.parentNode && el.parentNode.removeChild(el));
876880
}
877-
}, { once: true });
881+
};
882+
if (document.readyState === 'loading') {
883+
// Listen for DOM loaded because tags in the body couldnt
884+
// have loaded yet once the manager does it first render
885+
// (preferable there should only be one meta render on hydration)
886+
window.addEventListener('DOMContentLoaded', cleanUpSSR, { once: true });
887+
}
888+
else {
889+
cleanUpSSR();
890+
}
878891
}
879892
const teleports = {};
880893
for (const key in active) {
@@ -923,6 +936,7 @@ MetaManager.create = (isSSR, config, resolver) => {
923936
}
924937
return resolver.resolve(options, contexts, active, key, pathSegments);
925938
};
939+
const active = reactive({});
926940
const mergedObject = createMergedObject(resolve, active);
927941
// TODO: validate resolver
928942
const manager = new MetaManager(isSSR, config, mergedObject, resolver);

0 commit comments

Comments
 (0)