@m3e/web 2.1.0 → 2.1.1

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/all.js CHANGED
@@ -7541,6 +7541,9 @@ function isAttachInternalsMixin(value) {
7541
7541
  return hasKeys(value, internals);
7542
7542
  }
7543
7543
  const _internals = Symbol("_internals");
7544
+ // Since flushing custom state doesn't flush in Safari (affecting all iOS browsers),
7545
+ // a copy of custom state is retained locally so components can correctly read after write.
7546
+ const _customState = Symbol("_customState");
7544
7547
  /**
7545
7548
  * Mixin to augment an element with behavior that attaches to `ElementInternals`.
7546
7549
  * @template T The type of the base class.
@@ -7549,9 +7552,17 @@ const _internals = Symbol("_internals");
7549
7552
  * @returns {Constructor<AttachInternalsMixin> & T} A constructor that implements `AttachInternalsMixin`.
7550
7553
  */
7551
7554
  function AttachInternals(base, formAssociated) {
7555
+ var _a;
7552
7556
  class _AttachInternals extends base {
7557
+ constructor() {
7558
+ super(...arguments);
7559
+ // Since flushing custom state doesn't flush in Safari (affecting all iOS browsers),
7560
+ // a copy of custom state is retained locally so components can correctly read after write.
7561
+ /** @private */
7562
+ this[_a] = new Set();
7563
+ }
7553
7564
  /** @internal */
7554
- get [internals]() {
7565
+ get [(_a = _customState, internals)]() {
7555
7566
  return this[_internals] ?? (this[_internals] = this.attachInternals());
7556
7567
  }
7557
7568
  }
@@ -7566,6 +7577,13 @@ function AttachInternals(base, formAssociated) {
7566
7577
  * @returns {boolean} Whether `element` has `state`.
7567
7578
  */
7568
7579
  function hasCustomState(element, state) {
7580
+ // Since flushing custom state doesn't flush in Safari (affecting all iOS browsers),
7581
+ // a copy of custom state is retained locally so components can correctly read after write.
7582
+ if (_customState in element) {
7583
+ return element[_customState].has(state);
7584
+ }
7585
+ // This should never get called due to needing a local copy of custom state
7586
+ // since reading after write to flush doesn't work in Safari (affecting all iOS browsers).
7569
7587
  return element[internals].states.has(state);
7570
7588
  }
7571
7589
  /**
@@ -7574,8 +7592,13 @@ function hasCustomState(element, state) {
7574
7592
  * @param {string} state The custom state to add.
7575
7593
  */
7576
7594
  function addCustomState(element, state) {
7595
+ // Since flushing custom state doesn't flush in Safari (affecting all iOS browsers),
7596
+ // a copy of custom state is retained locally so components can correctly read after write.
7597
+ if (_customState in element) {
7598
+ element[_customState].add(state);
7599
+ }
7577
7600
  element[internals]?.states.add(state);
7578
- element[internals]?.states.has(state); // flush
7601
+ element[internals]?.states.has(state); // flush (even though this doesn't work in Safari)
7579
7602
  }
7580
7603
  /**
7581
7604
  * Convenience function used to delete custom state from an element.
@@ -7584,8 +7607,13 @@ function addCustomState(element, state) {
7584
7607
  * @returns {boolean} Whether `state` was removed from `element`.
7585
7608
  */
7586
7609
  function deleteCustomState(element, state) {
7610
+ // Since flushing custom state doesn't flush in Safari (affecting all iOS browsers),
7611
+ // a copy of custom state is retained locally so components can correctly read after write.
7612
+ if (_customState in element) {
7613
+ element[_customState].delete(state);
7614
+ }
7587
7615
  if (element[internals]?.states.delete(state)) {
7588
- element[internals]?.states.has(state); // flush
7616
+ element[internals]?.states.has(state); // flush (even though this doesn't work in Safari)
7589
7617
  return true;
7590
7618
  }
7591
7619
  return false;