Skip to content

Commit

Permalink
fix(App): component.is support ComponentDefinition | ComponentConstru…
Browse files Browse the repository at this point in the history
…ctor (question/140044)
  • Loading branch information
zhetengbiji committed Nov 25, 2022
1 parent f074e4e commit 7603d33
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/platforms/app-plus/service/framework/plugins/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ function setData (id, name, value) {
break
case V_FOR:
return setForData.call(this, id, value)
case 'is': {
if (typeof value === 'function') {
value = value.options
}
}
}

return ((this._$newData[id] || (this._$newData[id] = {}))[name] = value)
Expand Down
13 changes: 12 additions & 1 deletion src/platforms/app-plus/view/framework/plugins/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,18 @@ function vdSync ({

function getData (id, name) {
try {
return this.$r[id][name]
const data = this.$r[id][name]
if (name === 'is' && typeof data === 'object') {
const components = this.$options.components || {}
for (const key in components) {
const value = components[key]
const options = typeof value === 'function' ? value.options : value
if (options.__file === data.__file) {
return options
}
}
}
return data
} catch (e) {
// console.error(this.$options.__file + `:[${this._$id}]$r[${id}][${name}] is undefined`)
}
Expand Down

0 comments on commit 7603d33

Please sign in to comment.