Skip to content

Commit d9738d5

Browse files
fix: switch from scoped to shadow: true
so all components work with CSP rules
1 parent b2f4d4a commit d9738d5

File tree

6 files changed

+42
-12
lines changed

6 files changed

+42
-12
lines changed

core/api.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ ion-card,css-prop,--color,ios
504504
ion-card,css-prop,--color,md
505505
ion-card,part,native
506506

507-
ion-card-content,none
507+
ion-card-content,shadow
508508
ion-card-content,prop,mode,"ios" | "md",undefined,false,false
509509
ion-card-content,prop,theme,"ios" | "md" | "ionic",undefined,false,false
510510

@@ -931,7 +931,7 @@ ion-infinite-scroll-content,prop,loadingText,IonicSafeString | string | undefine
931931
ion-infinite-scroll-content,prop,mode,"ios" | "md",undefined,false,false
932932
ion-infinite-scroll-content,prop,theme,"ios" | "md" | "ionic",undefined,false,false
933933

934-
ion-input,scoped
934+
ion-input,shadow
935935
ion-input,prop,autocapitalize,string,'off',false,false
936936
ion-input,prop,autocomplete,"name" | "url" | "off" | "on" | "additional-name" | "address-level1" | "address-level2" | "address-level3" | "address-level4" | "address-line1" | "address-line2" | "address-line3" | "bday-day" | "bday-month" | "bday-year" | "cc-csc" | "cc-exp" | "cc-exp-month" | "cc-exp-year" | "cc-family-name" | "cc-given-name" | "cc-name" | "cc-number" | "cc-type" | "country" | "country-name" | "current-password" | "family-name" | "given-name" | "honorific-prefix" | "honorific-suffix" | "new-password" | "one-time-code" | "organization" | "postal-code" | "street-address" | "transaction-amount" | "transaction-currency" | "username" | "email" | "tel" | "tel-area-code" | "tel-country-code" | "tel-extension" | "tel-local" | "tel-national" | "nickname" | "organization-title" | "cc-additional-name" | "language" | "bday" | "sex" | "impp" | "photo",'off',false,false
937937
ion-input,prop,autocorrect,"off" | "on",'off',false,false
@@ -1028,7 +1028,7 @@ ion-input,css-prop,--placeholder-opacity,ionic
10281028
ion-input,css-prop,--placeholder-opacity,ios
10291029
ion-input,css-prop,--placeholder-opacity,md
10301030

1031-
ion-input-otp,scoped
1031+
ion-input-otp,shadow
10321032
ion-input-otp,prop,autocapitalize,string,'off',false,false
10331033
ion-input-otp,prop,color,"danger" | "dark" | "light" | "medium" | "primary" | "secondary" | "success" | "tertiary" | "warning" | string & Record<never, never> | undefined,undefined,false,true
10341034
ion-input-otp,prop,disabled,boolean,false,false,true
@@ -2415,7 +2415,7 @@ ion-text,prop,color,"danger" | "dark" | "light" | "medium" | "primary" | "second
24152415
ion-text,prop,mode,"ios" | "md",undefined,false,false
24162416
ion-text,prop,theme,"ios" | "md" | "ionic",undefined,false,false
24172417

2418-
ion-textarea,scoped
2418+
ion-textarea,shadow
24192419
ion-textarea,prop,autoGrow,boolean,false,false,true
24202420
ion-textarea,prop,autocapitalize,string,'none',false,false
24212421
ion-textarea,prop,autofocus,boolean,false,false,false

core/src/components/card-content/card-content.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { getIonTheme } from '../../global/ionic-global';
1414
md: 'card-content.md.scss',
1515
ionic: 'card-content.ionic.scss',
1616
},
17+
shadow: true,
1718
})
1819
export class CardContent implements ComponentInterface {
1920
render() {

core/src/components/datetime/datetime.tsx

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2111,6 +2111,35 @@ export class Datetime implements ComponentInterface {
21112111
);
21122112
}
21132113

2114+
private asBlob= (icon: string) => new Blob(
2115+
[Uint8Array.from(
2116+
icon.split("").map(function(c) {
2117+
return c.charCodeAt(0);
2118+
})
2119+
)],
2120+
{type: "image/svg+xml"}
2121+
);
2122+
2123+
private getIconProps(icon: string | undefined) {
2124+
if (typeof icon === 'string' && icon.trim().startsWith('data:image/svg+xml')) {
2125+
// Extract and decode the SVG string from the data URL
2126+
const svgString = decodeURIComponent(
2127+
atob(icon.split(',')[1])
2128+
.split('')
2129+
.map(function(c) {
2130+
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
2131+
})
2132+
.join('')
2133+
);
2134+
const url = URL.createObjectURL(this.asBlob(svgString));
2135+
console.log(url)
2136+
return { src: url};
2137+
}
2138+
// Ionicons icon name/object or undefined
2139+
return { icon };
2140+
}
2141+
2142+
21142143
/**
21152144
* Grid Render Methods
21162145
*/
@@ -2122,7 +2151,7 @@ export class Datetime implements ComponentInterface {
21222151
const nextMonthDisabled = disabled || isNextMonthDisabled(this.workingParts, this.maxParts);
21232152

21242153
// don't use the inheritAttributes util because it removes dir from the host, and we still need that
2125-
const hostDir = this.el.getAttribute('dir') || undefined;
2154+
21262155

21272156
return (
21282157
<div class="calendar-header">
@@ -2158,22 +2187,22 @@ export class Datetime implements ComponentInterface {
21582187
<ion-buttons>
21592188
<ion-button aria-label="Previous month" disabled={prevMonthDisabled} onClick={() => this.prevMonth()}>
21602189
<ion-icon
2161-
dir={hostDir}
2190+
//dir={hostDir}
21622191
aria-hidden="true"
21632192
slot="icon-only"
2164-
icon={datetimePreviousIcon}
21652193
lazy={false}
21662194
flipRtl
2195+
{...this.getIconProps(datetimePreviousIcon)}
21672196
></ion-icon>
21682197
</ion-button>
21692198
<ion-button aria-label="Next month" disabled={nextMonthDisabled} onClick={() => this.nextMonth()}>
21702199
<ion-icon
2171-
dir={hostDir}
2200+
//dir={hostDir}
21722201
aria-hidden="true"
21732202
slot="icon-only"
2174-
icon={datetimeNextIcon}
21752203
lazy={false}
21762204
flipRtl
2205+
{...this.getIconProps(datetimeNextIcon)}
21772206
></ion-icon>
21782207
</ion-button>
21792208
</ion-buttons>

core/src/components/input-otp/input-otp.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import type {
2323
md: 'input-otp.md.scss',
2424
ionic: 'input-otp.ionic.scss',
2525
},
26-
scoped: true,
26+
shadow: true,
2727
})
2828
export class InputOTP implements ComponentInterface {
2929
private inheritedAttributes: Attributes = {};

core/src/components/input/input.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ import { getCounterText } from './input.utils';
4646
md: 'input.md.scss',
4747
ionic: 'input.ionic.scss',
4848
},
49-
scoped: true,
49+
shadow: true,
5050
})
5151
export class Input implements ComponentInterface {
5252
private nativeInput?: HTMLInputElement;

core/src/components/textarea/textarea.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import type { TextareaChangeEventDetail, TextareaInputEventDetail } from './text
4343
md: 'textarea.md.scss',
4444
ionic: 'textarea.ionic.scss',
4545
},
46-
scoped: true,
46+
shadow: true,
4747
})
4848
export class Textarea implements ComponentInterface {
4949
private nativeInput?: HTMLTextAreaElement;

0 commit comments

Comments
 (0)