@ionic/react 8.7.13-dev.11766069240.1ab3dde2 → 8.7.13-dev.11766081813.18052ea1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +37 -1
- package/dist/index.js.map +1 -1
- package/dist/types/routing/PageManager.d.ts +7 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1149,8 +1149,39 @@ class PageManager extends React.PureComponent {
|
|
|
1149
1149
|
this.ionViewWillLeaveHandler = this.ionViewWillLeaveHandler.bind(this);
|
|
1150
1150
|
this.ionViewDidLeaveHandler = this.ionViewDidLeaveHandler.bind(this);
|
|
1151
1151
|
}
|
|
1152
|
+
parseClasses(className) {
|
|
1153
|
+
if (!className)
|
|
1154
|
+
return new Set();
|
|
1155
|
+
return new Set(className.split(/\s+/).filter(Boolean));
|
|
1156
|
+
}
|
|
1157
|
+
/**
|
|
1158
|
+
* Updates classList by diffing old/new className props.
|
|
1159
|
+
* Preserves framework-added classes (can-go-back, ion-page-invisible, etc.).
|
|
1160
|
+
*/
|
|
1161
|
+
updateUserClasses(oldClassName, newClassName) {
|
|
1162
|
+
if (!this.ionPageElementRef.current)
|
|
1163
|
+
return;
|
|
1164
|
+
const oldClasses = this.parseClasses(oldClassName);
|
|
1165
|
+
const newClasses = this.parseClasses(newClassName);
|
|
1166
|
+
oldClasses.forEach((cls) => {
|
|
1167
|
+
if (!newClasses.has(cls)) {
|
|
1168
|
+
this.ionPageElementRef.current.classList.remove(cls);
|
|
1169
|
+
}
|
|
1170
|
+
});
|
|
1171
|
+
newClasses.forEach((cls) => {
|
|
1172
|
+
if (!oldClasses.has(cls)) {
|
|
1173
|
+
this.ionPageElementRef.current.classList.add(cls);
|
|
1174
|
+
}
|
|
1175
|
+
});
|
|
1176
|
+
}
|
|
1152
1177
|
componentDidMount() {
|
|
1153
1178
|
if (this.ionPageElementRef.current) {
|
|
1179
|
+
// Add user classes via classList to preserve framework-added classes on re-renders
|
|
1180
|
+
if (this.props.className) {
|
|
1181
|
+
this.parseClasses(this.props.className).forEach((cls) => {
|
|
1182
|
+
this.ionPageElementRef.current.classList.add(cls);
|
|
1183
|
+
});
|
|
1184
|
+
}
|
|
1154
1185
|
if (this.context.isInOutlet()) {
|
|
1155
1186
|
this.ionPageElementRef.current.classList.add('ion-page-invisible');
|
|
1156
1187
|
}
|
|
@@ -1161,6 +1192,11 @@ class PageManager extends React.PureComponent {
|
|
|
1161
1192
|
this.ionPageElementRef.current.addEventListener('ionViewDidLeave', this.ionViewDidLeaveHandler);
|
|
1162
1193
|
}
|
|
1163
1194
|
}
|
|
1195
|
+
componentDidUpdate(prevProps) {
|
|
1196
|
+
if (prevProps.className !== this.props.className) {
|
|
1197
|
+
this.updateUserClasses(prevProps.className, this.props.className);
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1164
1200
|
componentWillUnmount() {
|
|
1165
1201
|
if (this.ionPageElementRef.current) {
|
|
1166
1202
|
this.ionPageElementRef.current.removeEventListener('ionViewWillEnter', this.ionViewWillEnterHandler);
|
|
@@ -1192,7 +1228,7 @@ class PageManager extends React.PureComponent {
|
|
|
1192
1228
|
const { className, children, routeInfo, forwardedRef, ...props } = this.props;
|
|
1193
1229
|
return (jsx(IonLifeCycleContext.Consumer, { children: (context) => {
|
|
1194
1230
|
this.ionLifeCycleContext = context;
|
|
1195
|
-
return (jsx("div", { className:
|
|
1231
|
+
return (jsx("div", { className: "ion-page", ref: this.stableMergedRefs, ...props, children: children }));
|
|
1196
1232
|
} }));
|
|
1197
1233
|
}
|
|
1198
1234
|
static get contextType() {
|