diff --git a/src/client/updaters/tag.js b/src/client/updaters/tag.js index dcfa7f86..1dcde157 100644 --- a/src/client/updaters/tag.js +++ b/src/client/updaters/tag.js @@ -1,3 +1,4 @@ +import { booleanHtmlAttributes } from '../../shared/constants' import { isUndefined } from '../../utils/is-type' import { toArray, includes } from '../../utils/array' @@ -51,7 +52,7 @@ export default function updateTag(appId, { attribute, tagIDKeyName } = {}, type, const _attr = includes(dataAttributes, attr) ? `data-${attr}` : attr - const value = isUndefined(tag[attr]) ? '' : tag[attr] + const value = isUndefined(tag[attr]) || booleanHtmlAttributes.includes(attr) ? '' : tag[attr] newElement.setAttribute(_attr, value) } } diff --git a/test/utils/meta-info-data.js b/test/utils/meta-info-data.js index 62bf81ad..7314b38a 100644 --- a/test/utils/meta-info-data.js +++ b/test/utils/meta-info-data.js @@ -124,7 +124,7 @@ const metaInfoData = { return () => { if (side === 'client') { for (const index in this.expect) { - this.expect[index] = this.expect[index].replace(/(async|defer)/g, '$1="true"') + this.expect[index] = this.expect[index].replace(/(async|defer)/g, '$1=""') } const tags = defaultTest() @@ -145,7 +145,7 @@ const metaInfoData = { // this test only runs for client so we can directly expect wrong boolean attributes change: { data: [{ src: 'src', async: true, defer: true, [defaultOptions.tagIDKeyName]: 'content2' }], - expect: [''] + expect: [''] }, remove: { data: [],