Skip to content

Commit

Permalink
Merge branch 'master' into fix-rn-dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
hiyuki authored Nov 22, 2024
2 parents 4721240 + d091a73 commit 4281183
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ module.exports = {
'@typescript-eslint/ban-types': 0,
'@typescript-eslint/no-empty-interface': 0,
'@typescript-eslint/no-unused-vars': 0,
'@typescript-eslint/no-non-null-assertion': 0,
camelcase: 0,
}
}
Expand Down
21 changes: 14 additions & 7 deletions packages/core/src/platform/patch/react/getDefaultOptions.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,28 +105,35 @@ function createInstance ({ propsRef, type, rawOptions, currentInject, validProps
this.__refs = {}
this.__dispatchedSlotSet = new WeakSet()
},
__getSlot (name) {
const result = []
__getSlot (name, slot) {
const { children } = propsRef.current
if (children) {
if (Array.isArray(children)) {
let result = []
if (Array.isArray(children) && !hasOwn(children, '__slot')) {
children.forEach(child => {
if (child?.props?.slot === name) {
if (hasOwn(child, '__slot')) {
if (child.__slot === name) result.push(...child)
} else if (child?.props?.slot === name) {
result.push(child)
}
})
} else {
if (children?.props?.slot === name) {
if (hasOwn(children, '__slot')) {
if (children.__slot === name) result.push(...children)
} else if (children?.props?.slot === name) {
result.push(children)
}
}
return result.filter(item => {
result = result.filter(item => {
if (!isObject(item) || this.__dispatchedSlotSet.has(item)) return false
this.__dispatchedSlotSet.add(item)
return true
})
if (!result.length) return null
result.__slot = slot
return result
}
return result
return null
},
__injectedRender: currentInject.render || noop,
__getRefsData: currentInject.getRefsData || noop,
Expand Down
3 changes: 2 additions & 1 deletion packages/webpack-plugin/lib/template-compiler/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -1374,7 +1374,8 @@ function processEvent (el, options) {
function processSlotReact (el, meta) {
if (el.tag === 'slot') {
el.slot = {
name: getAndRemoveAttr(el, 'name').val
name: getAndRemoveAttr(el, 'name').val,
slot: getAndRemoveAttr(el, 'slot').val
}
meta.options = meta.options || {}
meta.options.disableMemo = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ function genNode (node) {
return map
}, {})
if (node.slot) {
const name = node.slot.name
exp += `...__getSlot(${name ? s(name) : ''})`
const { name, slot } = node.slot
exp += `__getSlot(${name ? s(name) : ''}${slot ? `, ${s(slot)}` : ''})`
} else {
exp += `createElement(${`getComponent(${node.is || s(node.tag)})`}`
if (node.attrsList.length) {
Expand Down

0 comments on commit 4281183

Please sign in to comment.