Skip to content

Commit

Permalink
fix: slot should extra params
Browse files Browse the repository at this point in the history
  • Loading branch information
chilingling committed Dec 4, 2024
1 parent 7d0956f commit 19c83f2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/vue-generator/src/generator/vue/sfc/genSetupSFC.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
handleTinyGrid,
handleTinyIcon,
handleExpressionChildren,
validEmptyTemplateHook
validEmptyTemplateHook,
handleSlotParams
} from './generateTemplate'
import { generateStyleTag } from './generateStyle'
import {
Expand Down Expand Up @@ -213,6 +214,7 @@ export const genSFCWithDefaultPlugin = (schema, componentsMap, config = {}) => {
const defaultComponentHooks = [handleComponentNameHook, handleTinyIcon]

const defaultAttributeHook = [
handleSlotParams,
handleTinyGrid,
handleJsxModelValueUpdate,
handleConditionAttrHook,
Expand Down
18 changes: 18 additions & 0 deletions packages/vue-generator/src/generator/vue/sfc/generateTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,24 @@ export const handleTinyGrid = (schemaData, globalHooks, config) => {
})
}

export const handleSlotParams = (schemaData) => {
const { componentName, props } = schemaData.schema

if (componentName !== 'Slot' || !Array.isArray(props.params)) {
return
}

props.params.forEach((paramItem) => {
const { name, value } = paramItem || {}

if (name && value) {
props[name] = value
}
})

delete props.params
}

export const handleExpressionChildren = (schemaData = {}, globalHooks, config) => {
const { children, schema } = schemaData
const type = schema?.children?.type
Expand Down

0 comments on commit 19c83f2

Please sign in to comment.