Skip to content

Commit c290bea

Browse files
committed
chore(): sync with main
2 parents 98975ec + f2ed84a commit c290bea

File tree

13 files changed

+126
-47
lines changed

13 files changed

+126
-47
lines changed

.github/CONTRIBUTING.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Please see our [Contributor Code of Conduct](./CODE_OF_CONDUCT.md) for informati
4343
#### Modifying Components
4444

4545
1. Navigate to the `src/components/` directory and open the `icon` component to modify.
46-
2. Make any changes to the icon component and then [preview-changes](#preview-component-changes).
46+
2. Make any changes to the icon component and then [preview the changes](#preview-component-changes).
4747

4848

4949
#### Preview Component Changes
@@ -64,6 +64,10 @@ TODO -->
6464
3. Please fill out the Pull Request template to the best of your ability and include any issues that are related.
6565

6666

67+
## Updating Documentation
68+
69+
The documentation site for Ionicons is located in the [ionicons-site](https://github.com/ionic-team/ionicons-site) repository.
70+
6771
## License
6872

6973
By contributing your code to the ionic-team/ionicons GitHub Repository, you agree to license your contribution under the MIT license.

CHANGELOG.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,51 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## [6.1.3](https://github.com/ionic-team/ionicons/compare/v6.1.2...v6.1.3) (2023-02-09)
7+
8+
9+
### Bug Fixes
10+
11+
* DomParser usage in SSR ([#1180](https://github.com/ionic-team/ionicons/issues/1180)) ([8c412f6](https://github.com/ionic-team/ionicons/commit/8c412f67486d6cc9725de63f0c15b6c6cd8d47ce)), closes [#1179](https://github.com/ionic-team/ionicons/issues/1179)
12+
13+
14+
15+
16+
17+
## [6.1.2](https://github.com/ionic-team/ionicons/compare/v6.1.1...v6.1.2) (2023-02-08)
18+
19+
20+
### Bug Fixes
21+
22+
* **icon:** load base64 data urls ([#1172](https://github.com/ionic-team/ionicons/issues/1172)) ([72f0936](https://github.com/ionic-team/ionicons/commit/72f09369de76b00697437f54d919782307843a87))
23+
* **icon:** md and ios properties are reactive ([#1174](https://github.com/ionic-team/ionicons/issues/1174)) ([65bcbb4](https://github.com/ionic-team/ionicons/commit/65bcbb477734e33901a6f0c650d3f1f2c3084fca)), closes [#802](https://github.com/ionic-team/ionicons/issues/802)
24+
25+
26+
27+
28+
29+
## [6.1.1](https://github.com/ionic-team/ionicons/compare/v6.1.0...v6.1.1) (2023-01-18)
30+
31+
32+
### Bug Fixes
33+
34+
* **icon:** remove <title> during build step ([#1169](https://github.com/ionic-team/ionicons/issues/1169)) ([93b4fa4](https://github.com/ionic-team/ionicons/commit/93b4fa449b0a072b24ef920fe73e1cb04d6f9b43)), closes [#1168](https://github.com/ionic-team/ionicons/issues/1168)
35+
36+
37+
38+
39+
40+
## [6.1.1](https://github.com/ionic-team/ionicons/compare/v6.1.0...v6.1.1) (2023-01-18)
41+
42+
43+
### Bug Fixes
44+
45+
* **icon:** remove <title> during build step ([#1169](https://github.com/ionic-team/ionicons/issues/1169)) ([93b4fa4](https://github.com/ionic-team/ionicons/commit/93b4fa449b0a072b24ef920fe73e1cb04d6f9b43)), closes [#1168](https://github.com/ionic-team/ionicons/issues/1168)
46+
47+
48+
49+
50+
651
# [6.1.0](https://github.com/ionic-team/ionicons/compare/v6.0.4...v6.1.0) (2023-01-17)
752

853

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"packages": [
33
"./"
44
],
5-
"version": "6.1.0"
5+
"version": "6.1.3"
66
}

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ionicons",
3-
"version": "6.1.0",
3+
"version": "6.1.3",
44
"description": "Premium icons for Ionic.",
55
"files": [
66
"components/",

src/components/icon/icon.tsx

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import { Build, Component, Element, Host, Prop, State, Watch, h } from '@stencil
22
import { getSvgContent, ioniconContent } from './request';
33
import { getName, getUrl, inheritAttributes, isRTL } from './utils';
44

5-
let parser: DOMParser;
6-
75
@Component({
86
tag: 'ion-icon',
97
assetsDirs: ['svg'],
@@ -81,7 +79,7 @@ export class Icon {
8179
* @default true
8280
*/
8381
@Prop() sanitize = true;
84-
82+
8583
componentWillLoad() {
8684
this.inheritedAttributes = inheritAttributes(this.el, ['aria-label']);
8785
}
@@ -127,29 +125,16 @@ export class Icon {
127125
@Watch('name')
128126
@Watch('src')
129127
@Watch('icon')
128+
@Watch('ios')
129+
@Watch('md')
130130
loadIcon() {
131131
if (Build.isBrowser && this.isVisible) {
132-
if (!parser) {
133-
/**
134-
* Create an instance of the DOM parser. This creates a single
135-
* parser instance for the entire app, which is more efficient.
136-
*/
137-
parser = new DOMParser();
138-
}
139132
const url = getUrl(this);
140133

141134
if (url) {
142135
if (ioniconContent.has(url)) {
143136
// sync if it's already loaded
144137
this.svgContent = ioniconContent.get(url);
145-
} else if (url.startsWith('data:')) {
146-
const doc = parser.parseFromString(url, 'text/html');
147-
const svgEl = doc.body.querySelector('svg');
148-
if (svgEl !== null) {
149-
this.svgContent = svgEl.outerHTML;
150-
} else {
151-
this.svgContent = '';
152-
}
153138
} else {
154139
// async if it hasn't been loaded
155140
getSvgContent(url, this.sanitize).then(() => (this.svgContent = ioniconContent.get(url)));
@@ -165,9 +150,7 @@ export class Icon {
165150
const mode = this.mode || 'md';
166151
const flipRtl =
167152
this.flipRtl ||
168-
(iconName &&
169-
(iconName.indexOf('arrow') > -1 || iconName.indexOf('chevron') > -1) &&
170-
this.flipRtl !== false);
153+
(iconName && (iconName.indexOf('arrow') > -1 || iconName.indexOf('chevron') > -1) && this.flipRtl !== false);
171154

172155
return (
173156
<Host

src/components/icon/request.ts

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,51 @@
1-
import { validateContent } from './validate';
1+
import { isEncodedDataUrl, isSvgDataUrl, validateContent } from './validate';
22

33
export const ioniconContent = new Map<string, string>();
44
const requests = new Map<string, Promise<any>>();
55

6+
let parser: DOMParser;
7+
68
export const getSvgContent = (url: string, sanitize: boolean) => {
79
// see if we already have a request for this url
810
let req = requests.get(url);
911

1012
if (!req) {
1113
if (typeof fetch !== 'undefined' && typeof document !== 'undefined') {
12-
// we don't already have a request
13-
req = fetch(url).then((rsp) => {
14-
if (rsp.ok) {
15-
return rsp.text().then((svgContent) => {
16-
if (svgContent && sanitize !== false) {
17-
svgContent = validateContent(svgContent);
18-
}
19-
ioniconContent.set(url, svgContent || '');
20-
});
14+
/**
15+
* If the url is a data url of an svg, then try to parse it
16+
* with the DOMParser. This works with content security policies enabled.
17+
*/
18+
if (isSvgDataUrl(url) && isEncodedDataUrl(url)) {
19+
if (!parser) {
20+
/**
21+
* Create an instance of the DOM parser. This creates a single
22+
* parser instance for the entire app, which is more efficient.
23+
*/
24+
parser = new DOMParser();
25+
}
26+
const doc = parser.parseFromString(url, 'text/html');
27+
const svg = doc.querySelector('svg');
28+
if (svg) {
29+
ioniconContent.set(url, svg.outerHTML);
2130
}
22-
ioniconContent.set(url, '');
23-
});
31+
return Promise.resolve();
32+
} else {
33+
// we don't already have a request
34+
req = fetch(url).then((rsp) => {
35+
if (rsp.ok) {
36+
return rsp.text().then((svgContent) => {
37+
if (svgContent && sanitize !== false) {
38+
svgContent = validateContent(svgContent);
39+
}
40+
ioniconContent.set(url, svgContent || '');
41+
});
42+
}
43+
ioniconContent.set(url, '');
44+
});
45+
// cache for the same requests
46+
requests.set(url, req);
47+
}
2448

25-
// cache for the same requests
26-
requests.set(url, req);
2749
} else {
2850
// set to empty for ssr scenarios and resolve promise
2951
ioniconContent.set(url, '');
-8.65 KB
Loading
-1.61 KB
Loading
4.83 KB
Loading

0 commit comments

Comments
 (0)