diff --git a/packages/uni-template-compiler/lib/app/parser/component-parser.js b/packages/uni-template-compiler/lib/app/parser/component-parser.js index 4df668ac81469f1d78e60d6bc680d1559dfab503..db856acbb8c18ba7bccabaa1389084efa648f0a5 100644 --- a/packages/uni-template-compiler/lib/app/parser/component-parser.js +++ b/packages/uni-template-compiler/lib/app/parser/component-parser.js @@ -1,5 +1,6 @@ const { - ID + ID, + elements } = require('../util') const { @@ -9,7 +10,7 @@ const { // 仅限 view 层 module.exports = function parseComponent (el) { // 需要把自定义组件的 attrs, props 全干掉 - if (el.tag && isComponent(el.tag)) { + if (el.tag && !elements.includes(el.tag) && isComponent(el.tag)) { // 仅保留 id、ID、data el.attrs && (el.attrs = el.attrs.filter(attr => { const name = attr.name diff --git a/packages/uni-template-compiler/lib/app/parser/tag-parser.js b/packages/uni-template-compiler/lib/app/parser/tag-parser.js index 70e7d0dc0b4249c023802950ceb63ca0673d7c12..748be40d69ba2850a4ffa1eeeeac4cb86ac64bed 100644 --- a/packages/uni-template-compiler/lib/app/parser/tag-parser.js +++ b/packages/uni-template-compiler/lib/app/parser/tag-parser.js @@ -1,12 +1,10 @@ const { - hasOwn + hasOwn, + elements } = require('../util') const tags = require('@dcloudio/uni-cli-shared/lib/tags') -// web components -const elements = ['uni-view'] - // 仅限 view 层 module.exports = function parseTag (el) { const tag = el.tag diff --git a/packages/uni-template-compiler/lib/app/util.js b/packages/uni-template-compiler/lib/app/util.js index 429286756f372f618f0341e6e805015fc8381508..3de296a6118b97f1890615b8030268b653bc992f 100644 --- a/packages/uni-template-compiler/lib/app/util.js +++ b/packages/uni-template-compiler/lib/app/util.js @@ -20,6 +20,9 @@ const V_FOR = 'f' const V_IF = 'i' const V_ELSE_IF = 'e' +// web components +const elements = ['uni-view'] + function isVar (str) { if (!str) { return false @@ -273,6 +276,7 @@ module.exports = { GET_DATA, SET_MP_CLASS, GET_CHANGE_DATA, + elements, isVar, hasOwn, addAttr, @@ -288,4 +292,4 @@ module.exports = { getBindingAttr, getAndRemoveAttr, traverseNode -} +} diff --git a/packages/uni-template-compiler/lib/util.js b/packages/uni-template-compiler/lib/util.js index 5e68bb7dc448d310a7861de4cece433f8d41069c..ea35f9c704e1c8ac9e2101aa54946f5279dd1c73 100644 --- a/packages/uni-template-compiler/lib/util.js +++ b/packages/uni-template-compiler/lib/util.js @@ -210,7 +210,7 @@ function isComponent (tagName) { return false } } - return !hasOwn(tags, getTagName(tagName.replace(/^(v-)?uni-/, ''))) + return !hasOwn(tags, getTagName(tagName.replace(/^v-uni-/, ''))) } function makeMap (str, expectsLowerCase) {