Skip to content

Commit

Permalink
SK-1104 minimize the fetching of card icons.
Browse files Browse the repository at this point in the history
  • Loading branch information
yaswanth-pula-skyflow committed Sep 28, 2023
1 parent 3fa04e6 commit f160333
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/core/internal/iframe-form/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
FRAME_ELEMENT,
DEFAULT_ERROR_TEXT_ELEMENT_TYPES,
DEFAULT_REQUIRED_TEXT_ELEMENT_TYPES,
CardType,
} from '../../constants';
import EventEmitter from '../../../event-emitter';
import regExFromString from '../../../libs/regex';
Expand Down Expand Up @@ -107,6 +108,8 @@ export class IFrameFormElement extends EventEmitter {

containerType: string;

cardType: string = CardType.DEFAULT;

constructor(name: string, label: string, metaData, context: Context, skyflowID?: string) {
super();
const frameValues = name.split(':');
Expand Down
9 changes: 6 additions & 3 deletions src/core/internal/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,12 @@ export class FrameElement {
}
if (this.iFrameFormElement.fieldType === ELEMENTS.CARD_NUMBER.name) {
const cardType = detectCardType(state.value);
if (this.options.enableCardIcon) {
if (this.domImg) {
this.domImg.src = CARD_ENCODED_ICONS[cardType] || 'none';
if (cardType !== this.iFrameFormElement.cardType) {
if (this.options.enableCardIcon) {
if (this.domImg) {
this.domImg.src = CARD_ENCODED_ICONS[cardType] || 'none';
this.iFrameFormElement.cardType = cardType;
}
}
}
const cardNumberMask = addSeperatorToCardNumberMask(
Expand Down

0 comments on commit f160333

Please sign in to comment.