lwc icon indicating copy to clipboard operation
lwc copied to clipboard

[Pivots] Support form-associate custom element (FACE) callbacks

Open nolanlawson opened this issue 2 years ago • 1 comments

Description

As seen in Polymer's implementation, pivots (#2724) should support FACE callbacks such as formAssociatedCallback and formDisabledCallback.

nolanlawson avatar Aug 11 '22 16:08 nolanlawson

This issue has been linked to a new work item: W-11585205

git2gus[bot] avatar Aug 11 '22 16:08 git2gus[bot]

I started implementing this, but there is an interesting wrinkle: FACE assumes you add static formAssociated = true to your custom element class, similar to how static observedAttributes work.

So you only get one chance to make an element form-associated. This is a problem if we have class A which is registered first and not form-associated, and then class B which is registered second and is form-associated. A few possibilities:

  1. Set static formAssociated = true for every PivotCtor, just in case someone wants to be form-associated. If the callback is invoked by the browser on a non-form-associated element, just ignore it.
  2. Avoid setting static formAssociated = true for class A, and then implement some kind of polyfill for class B.

Both options make me nervous. FWIW Polymer's polyfill seems to go for option #1 but not bother to ignore FACE callbacks for non-FACE elements.

nolanlawson avatar Oct 19 '22 20:10 nolanlawson

At this point name collision should not be a thing... so we should be fine to use formAssociated if the Ctor has it at the time of declaration of the upgradable class.

caridy avatar Jan 25 '23 15:01 caridy

Pivots were dropped in #3310

nolanlawson avatar Jan 27 '23 00:01 nolanlawson

@rwaldron do we need this in locker?

caridy avatar Jan 30 '23 14:01 caridy