mirror of
https://github.com/tenrok/vue-meta.git
synced 2026-06-24 12:00:33 +03:00
refactor: optimize callback attribute
This commit is contained in:
@@ -14,7 +14,7 @@ import {
|
|||||||
* @return {Object} - the tag generator
|
* @return {Object} - the tag generator
|
||||||
*/
|
*/
|
||||||
export default function tagGenerator ({ ssrAppId, attribute, tagIDKeyName } = {}, type, tags) {
|
export default function tagGenerator ({ ssrAppId, attribute, tagIDKeyName } = {}, type, tags) {
|
||||||
const dataAttributes = [tagIDKeyName, 'callback', ...commonDataAttributes]
|
const dataAttributes = [tagIDKeyName, ...commonDataAttributes]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
text ({ body = false, pbody = false } = {}) {
|
text ({ body = false, pbody = false } = {}) {
|
||||||
@@ -43,17 +43,17 @@ export default function tagGenerator ({ ssrAppId, attribute, tagIDKeyName } = {}
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (attr === 'callback') {
|
||||||
|
attrs += ` onload="this.__vm_l=1"`
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// these form the attribute list for this tag
|
// these form the attribute list for this tag
|
||||||
let prefix = ''
|
let prefix = ''
|
||||||
if (dataAttributes.includes(attr)) {
|
if (dataAttributes.includes(attr)) {
|
||||||
prefix = 'data-'
|
prefix = 'data-'
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attr === 'callback') {
|
|
||||||
attrs += ` onload="this.__vm_l=1"`
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
const isBooleanAttr = !prefix && booleanHtmlAttributes.includes(attr)
|
const isBooleanAttr = !prefix && booleanHtmlAttributes.includes(attr)
|
||||||
if (isBooleanAttr && !tag[attr]) {
|
if (isBooleanAttr && !tag[attr]) {
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user