@ionic/react 8.8.19-dev.11787007863.1976a30e → 8.8.19-dev.11787076261.138d5922

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 CHANGED
@@ -1084,6 +1084,13 @@ const NON_BOOLEAN_FALSE_ATTRIBUTES = new Set(['draggable', 'translate', 'spell-c
1084
1084
  * can be removed once React 18 support is dropped.
1085
1085
  */
1086
1086
  const isStaleFalseBooleanAttribute = (attribute) => !attribute.startsWith('aria-') && !attribute.startsWith('data-') && !NON_BOOLEAN_FALSE_ATTRIBUTES.has(attribute);
1087
+ /**
1088
+ * Assigning `undefined` or `null` to a reflected prop like `id` writes the stringified value, so
1089
+ * the element ends up with `id="undefined"` or `id="null"`. Only native properties are cleaned up
1090
+ * here: a nullish component prop still has to reach the component, and Stencil clears the
1091
+ * attribute for props declared `reflect: true`.
1092
+ */
1093
+ const isNativeElementProperty = (name) => name in HTMLElement.prototype;
1087
1094
  const attachProps = (node, newProps, oldProps = {}) => {
1088
1095
  // some test frameworks don't render DOM elements, so we test here to make sure we are dealing with DOM first
1089
1096
  if (node instanceof Element) {
@@ -1109,12 +1116,19 @@ const attachProps = (node, newProps, oldProps = {}) => {
1109
1116
  }
1110
1117
  }
1111
1118
  else {
1112
- node[name] = newProps[name];
1113
- const propType = typeof newProps[name];
1119
+ const value = newProps[name];
1120
+ node[name] = value;
1121
+ if ((value === undefined || value === null) && isNativeElementProperty(name)) {
1122
+ // Remove both spellings: the property reflects `accesskey`, and dash-casing writes `access-key`.
1123
+ node.removeAttribute(name);
1124
+ node.removeAttribute(camelToDashCase(name));
1125
+ return;
1126
+ }
1127
+ const propType = typeof value;
1114
1128
  if (propType === 'string') {
1115
- node.setAttribute(camelToDashCase(name), newProps[name]);
1129
+ node.setAttribute(camelToDashCase(name), value);
1116
1130
  }
1117
- else if (newProps[name] === false) {
1131
+ else if (value === false) {
1118
1132
  const attribute = camelToDashCase(name);
1119
1133
  if (isStaleFalseBooleanAttribute(attribute)) {
1120
1134
  node.removeAttribute(attribute);
@@ -2935,6 +2949,13 @@ function useOverlay(displayName, controller, defineCustomElement, component, com
2935
2949
  };
2936
2950
  }
2937
2951
 
2952
+ // TODO(FW-2959): types
2953
+ /**
2954
+ * A hook for presenting/dismissing an IonModal component
2955
+ * @param component The component that the modal will show. Can be a React Component, a functional component, or a JSX Element
2956
+ * @param componentProps The props that will be passed to the component, if required
2957
+ * @returns Returns the present and dismiss methods in an array
2958
+ */
2938
2959
  function useIonModal(component, componentProps) {
2939
2960
  const controller = useOverlay('IonModal', modalController, defineCustomElement$1c, component, componentProps);
2940
2961
  const present = useCallback((options = {}) => {
@@ -2943,6 +2964,13 @@ function useIonModal(component, componentProps) {
2943
2964
  return [present, controller.dismiss];
2944
2965
  }
2945
2966
 
2967
+ // TODO(FW-2959): types
2968
+ /**
2969
+ * A hook for presenting/dismissing an IonPicker component
2970
+ * @param component The component that the popover will show. Can be a React Component, a functional component, or a JSX Element
2971
+ * @param componentProps The props that will be passed to the component, if required
2972
+ * @returns Returns the present and dismiss methods in an array
2973
+ */
2946
2974
  function useIonPopover(component, componentProps) {
2947
2975
  const controller = useOverlay('IonPopover', popoverController, defineCustomElement$1d, component, componentProps);
2948
2976
  const present = useCallback((options = {}) => {