Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(h5): web 平台调整 audio 为原生元素 #5150

Open
wants to merge 3 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions packages/uni-cli-shared/src/vue/transforms/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@ export {
} from './vModel'

export const transformH5BuiltInComponents = createTransformTag(
BUILT_IN_TAG_NAMES.reduce<Record<string, string>>(
(tags, tag) => ((tags[tag] = COMPONENT_PREFIX + tag), tags),
{}
)
BUILT_IN_TAG_NAMES.reduce<Record<string, string>>((tags, tag) => {
if (tag === 'audio') {
return tags
}
tags[tag] = COMPONENT_PREFIX + tag
return tags
}, {})
)

export const transformMatchMedia = createTransformTag({
Expand Down
17 changes: 16 additions & 1 deletion packages/uni-shared/src/tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,26 @@ export function isUniXElement(name: string) {
return /^I?Uni.*Element(?:Impl)?$/.test(name)
}

let isAudioWarned = false

function isBuiltInWebComponent(tag: string) {
if (tag === 'audio') {
if (!isAudioWarned) {
console.warn(
'HBuilderX 4.28 版本起,Web 平台 Audio 组件从内置组件调整为原生元素,请参考 https://uniapp.dcloud.net.cn/component/audio.html'
)
isAudioWarned = true
}
return false
}
return isBuiltInComponent(tag)
}

export function isH5NativeTag(tag: string) {
return (
tag !== 'head' &&
(isHTMLTag(tag) || isSVGTag(tag)) &&
!isBuiltInComponent(tag)
!isBuiltInWebComponent(tag)
)
}

Expand Down
Loading