mirror of
https://github.com/tenrok/vue-meta.git
synced 2026-06-23 12:40:34 +03:00
fix: follow html specs with regards to end tags (#314)
This commit is contained in:
+8
-9
@@ -1,19 +1,18 @@
|
|||||||
language: node_js
|
language: node_js
|
||||||
|
node_js:
|
||||||
|
- "8"
|
||||||
|
- "11"
|
||||||
cache:
|
cache:
|
||||||
|
yarn: true
|
||||||
directories:
|
directories:
|
||||||
- $HOME/.npm
|
|
||||||
- $HOME/.yarn-cache
|
|
||||||
- node_modules
|
- node_modules
|
||||||
branches:
|
branches:
|
||||||
only:
|
only:
|
||||||
- master
|
- master
|
||||||
node_js:
|
|
||||||
- "6"
|
|
||||||
before_install:
|
|
||||||
- npm i -g yarn --cache-min 999999999
|
|
||||||
install:
|
install:
|
||||||
- yarn --force
|
- yarn install
|
||||||
script:
|
script:
|
||||||
|
- yarn lint
|
||||||
- yarn test
|
- yarn test
|
||||||
after_script:
|
after_success:
|
||||||
- yarn run codecov
|
- yarn codecov
|
||||||
|
|||||||
@@ -37,17 +37,20 @@ export default function _tagGenerator (options = {}) {
|
|||||||
// grab child content from one of these attributes, if possible
|
// grab child content from one of these attributes, if possible
|
||||||
const content = tag.innerHTML || tag.cssText || ''
|
const content = tag.innerHTML || tag.cssText || ''
|
||||||
|
|
||||||
// these tag types will have content inserted
|
|
||||||
const closed = ['noscript', 'script', 'style'].indexOf(type) === -1
|
|
||||||
|
|
||||||
// generate tag exactly without any other redundant attribute
|
// generate tag exactly without any other redundant attribute
|
||||||
const observeTag = tag.once
|
const observeTag = tag.once
|
||||||
? ''
|
? ''
|
||||||
: `${attribute}="true" `
|
: `${attribute}="true" `
|
||||||
|
|
||||||
|
// these tags have no end tag
|
||||||
|
const hasEndTag = !['base', 'meta', 'link'].includes(type)
|
||||||
|
|
||||||
|
// these tag types will have content inserted
|
||||||
|
const hasContent = hasEndTag && ['noscript', 'script', 'style'].includes(type)
|
||||||
|
|
||||||
// the final string for this specific tag
|
// the final string for this specific tag
|
||||||
return closed
|
return !hasContent
|
||||||
? `${tagsStr}<${type} ${observeTag}${attrs}/>`
|
? `${tagsStr}<${type} ${observeTag}${attrs}${hasEndTag ? '/' : ''}>`
|
||||||
: `${tagsStr}<${type} ${observeTag}${attrs}>${content}</${type}>`
|
: `${tagsStr}<${type} ${observeTag}${attrs}>${content}</${type}>`
|
||||||
}, '')
|
}, '')
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user