-
Notifications
You must be signed in to change notification settings - Fork 382
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1737 from didi/fix-components-name-conflict
fix: rn components name conflict
- Loading branch information
Showing
3 changed files
with
37 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 15 additions & 12 deletions
27
packages/webpack-plugin/lib/platform/template/wx/component-config/fix-component-name.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,24 @@ | ||
const { isOriginTag, isBuildInTag } = require('../../../../utils/dom-tag-config') | ||
|
||
module.exports = function () { | ||
const handleComponentTag = (el, data) => { | ||
const newTag = `mpx-com-${el.tag}` | ||
const usingComponents = data.usingComponents || [] | ||
// 当前组件名与原生tag或内建tag同名,对组件名进行转义 | ||
// json转义见:platform/json/wx/index.js fixComponentName | ||
if (usingComponents.includes(newTag)) { | ||
el.tag = newTag | ||
} | ||
return el | ||
} | ||
|
||
return { | ||
waterfall: true, | ||
skipNormalize: true, | ||
supportedModes: ['web'], | ||
supportedModes: ['web', 'ios', 'android'], | ||
test: (input) => isOriginTag(input) || isBuildInTag(input), | ||
// 输出web时对组件名进行转义避免与原生tag和内建tag冲突 | ||
web (el, data) { | ||
const newTag = `mpx-com-${el.tag}` | ||
const usingComponents = data.usingComponents || [] | ||
// 当前组件名与原生tag或内建tag同名,对组件名进行转义 | ||
// json转义见:platform/json/wx/index.js fixComponentName | ||
if (usingComponents.includes(newTag)) { | ||
el.tag = newTag | ||
} | ||
return el | ||
} | ||
web: handleComponentTag, | ||
ios: handleComponentTag, | ||
android: handleComponentTag | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters