Skip to content

Commit

Permalink
fix(*): fix istext.
Browse files Browse the repository at this point in the history
  • Loading branch information
shangqunfeng committed May 31, 2024
1 parent 20dc607 commit c5c31ec
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import useInnerProps from './getInnerListeners'
// @ts-ignore
import useNodesRef from '../../useNodesRef' // 引入辅助函数

import { parseUrl, hasElementType, TEXT_STYLE_REGEX, PERCENT_REGX } from './utils'
import { parseUrl, TEXT_STYLE_REGEX, PERCENT_REGX } from './utils'

type ElementNode = React.ReactNode

Expand Down Expand Up @@ -237,8 +237,9 @@ function splitStyle(styles: ExtendedViewStyle) {
}, {})
}

const isText = (children: ElementNode) => {
return hasElementType(children, 'mpx-text') || hasElementType(children, 'Text')
const isText = (ele: ElementNode) => {
const displayName = ele?.type?.displayName
return displayName === 'mpx-text' || displayName === 'Text'
}

function every(children: ElementNode, callback: (children: ElementNode) => boolean ) {
Expand Down
5 changes: 0 additions & 5 deletions packages/webpack-plugin/lib/runtime/components/react/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,6 @@ export const parseUrl = (cssUrl: string = '') => {
return match?.[1]
}

export const hasElementType = (element: ReactNode, type: string) => {
if (!element) return false
return (element as any)?.type?.displayName === type
}

export const getRestProps = (transferProps: any = {}, originProps: any = {}, deletePropsKey: any = []) => {
return {
...transferProps,
Expand Down

0 comments on commit c5c31ec

Please sign in to comment.