From 7d4609e233097998e24b861c1984e4d6b4acde55 Mon Sep 17 00:00:00 2001 From: samarinsergey Date: Wed, 20 Mar 2024 16:29:22 +0300 Subject: [PATCH] [HOS-2076] apply theme to Swiper component --- compiler/src/pre_define.ts | 2 ++ compiler/src/process_component_build.ts | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/compiler/src/pre_define.ts b/compiler/src/pre_define.ts index 0e4bf670..e07a80fd 100644 --- a/compiler/src/pre_define.ts +++ b/compiler/src/pre_define.ts @@ -347,6 +347,8 @@ export const SLIDER: string = 'Slider'; export const STEPPER: string = 'Stepper'; export const INDEX: string = 'index'; export const SWIPER: string = 'Swiper'; +export const SWIPER_DISPLAY_ARROW_ATTR: string = 'displayArrow'; +export const SWIPER_INDICATOR_ATTR: string = 'indicator'; export const TABS: string = 'Tabs'; export const TEXT_AREA: string = 'TextArea'; export const TEXT: string = 'text'; diff --git a/compiler/src/process_component_build.ts b/compiler/src/process_component_build.ts index 8652d4c1..bbfc8bea 100644 --- a/compiler/src/process_component_build.ts +++ b/compiler/src/process_component_build.ts @@ -146,6 +146,9 @@ import { CHECKBOX_GROUP, ALPHABET_INDEXER, SELECT, + SWIPER, + SWIPER_DISPLAY_ARROW_ATTR, + SWIPER_INDICATOR_ATTR, COMPONENT_GET_PARENT_THEME } from './pre_define'; import { @@ -217,6 +220,7 @@ const componentsAppliedWithTheme: Set = new Set([ SEARCH, SELECT, SLIDER, + SWIPER, TEXT_PICKER, TEXT_INPUT, TIME_PICKER, @@ -2578,6 +2582,7 @@ function addComponentAttr(temp: any, node: ts.Identifier, lastStatement: any, newImmutableStatements: ts.Statement[] = null, isRecycleComponent: boolean = false, isStyleFunction: boolean = false): void { const propName: string = node.getText(); + const className: string | undefined = identifierNode?.escapedText?.toString(); verifyComponentId(temp, node, propName, log); const extendType: ExtendType = {type: ''}; if (propName === ATTRIBUTE_ANIMATION) { @@ -2662,9 +2667,8 @@ function addComponentAttr(temp: any, node: ts.Identifier, lastStatement: any, } else { temp = loopEtscomponent(temp, isStylesAttr); if (propName !== RECYCLE_REUSE_ID) { - const isAttributeModifier: boolean = componentsStyles.has(propName) const attrStatement: ts.Statement = ts.factory.createExpressionStatement( - createFunction(identifierNode, node, temp.arguments, isAttributeModifier)); + createFunction(identifierNode, node, temp.arguments, isAttributeModifier(className, propName))); statements.push(attrStatement); if (isRecycleComponent && (!isStylesAttr || isStyleFunction) && !isGestureType(identifierNode) && filterRegularAttrNode(temp.arguments)) { @@ -3311,3 +3315,8 @@ function checkNonspecificParents(node: ts.ExpressionStatement, name: string, sav } } } + +function isAttributeModifier(className: string, propName: string): boolean { + return componentsStyles.has(propName) || + (className === SWIPER && (propName === SWIPER_INDICATOR_ATTR || propName === SWIPER_DISPLAY_ARROW_ATTR)); +} \ No newline at end of file -- Gitee