@ionic/react 8.8.19-dev.11786730389.1a1927bf → 8.8.19-dev.11786832241.150538c7

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);