vuepress / vuepress-theme-blog

Default blog theme for VuePress.
https://vuepress-theme-blog.billyyyyy3320.com/
MIT License
211 stars 129 forks source link

JavaScript error due to <meta> tag in template #78

Closed chriscdn closed 3 years ago

chriscdn commented 4 years ago

Bug report

In this commit a <meta> tag is added to the page. This causes VuePress to throw an error since the updateMetaTags() function in updateMeta.js assumes (correctly) that all <meta> tags are below <head>.

Steps to reproduce

What is expected?

No JavaScript error.

What is actually happening?

{"stack":"Error: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.\n at /assets/js/app.bff2e1e0.js:8:102722\n at Array.forEach ()\n at Xt (/assets/js/app.bff2e1e0.js:8:102687)\n at i.updateMeta (/assets/js/app.bff2e1e0.js:8:102369)\n at i.mounted (/assets/js/app.bff2e1e0.js:8:102204)\n at Bt (/assets/js/app.bff2e1e0.js:6:11294)\n at Qe (/assets/js/app.bff2e1e0.js:6:25252)\n at Object.insert (/assets/js/app.bff2e1e0.js:6:20274)\n at O (/assets/js/app.bff2e1e0.js:6:56250)\n at _n.patch (/assets/js/app.bff2e1e0.js:6:57204)"} /assets/js/app.bff2e1e0.js:6

Other relevant information

billyyyyy3320 commented 4 years ago

Thanks for the report.

billyyyyy3320 commented 4 years ago

When a <meta> tag contains itemprop attr, it's allowed to be placed inside html body.

I suppose this issue could be resolved by updating updateMeta.js file or leveraging itemref attr. @Kocal Would you like to resolve it?

Kocal commented 4 years ago

Yes I can take a look, I will try to work on it tonight.

Kocal commented 4 years ago

PR opened at https://github.com/vuejs/vuepress/pull/2403

I prefered to check over <meta> parent element instead of checking if itemref attribute exists, because it seems that <meta itemprop="..."> are also accepted in <head> (https://stackoverflow.com/a/22415563)

What do you think?

billyyyyy3320 commented 3 years ago

Close it due to vuejs/vuepress#2403 has been merged and released.