Class: InpostGeowidgetManager
InPost Geowidget v5.
Two things about this widget are easy to get wrong and cost a broken checkout:
- It reports the picked point through a GLOBAL function, named by the
onpointattribute — not through an event listener. Each instance registers its own uniquely named function so two maps on one page cannot overwrite each other, and removes it on teardown. - Its token is read once, when the element connects to the document. Setting the attribute afterwards is silently ignored: the first open looks fine (the script is still loading, so the upgrade happens after the attribute lands) and the SECOND opens an empty map. Hence the imperative creation with attributes set up-front.
- The global callback receives the point payload FLAT, not wrapped in
{ detail }. The widget only wraps the payload in a CustomEvent when no global function is registered — and this manager always registers one. Readingevent.detail.namealone silently drops every selection: the map works, but picking a point does nothing.
Extends
Constructors
Constructor
new InpostGeowidgetManager(
options):InpostGeowidgetManager
Parameters
options
Returns
InpostGeowidgetManager
Inherited from
AbstractPickupWidgetManager.constructor
Properties
container
protectedcontainer:HTMLElement|null=null
Inherited from
AbstractPickupWidgetManager.container
descriptor
protectedreadonlydescriptor:PickupWidgetDescriptor
Inherited from
AbstractPickupWidgetManager.descriptor
element
protectedelement:HTMLElement|null=null
Inherited from
AbstractPickupWidgetManager.element
onSelect
protectedreadonlyonSelect: (point) =>void
Parameters
point
Returns
void
Inherited from
AbstractPickupWidgetManager.onSelect
token
protectedreadonlytoken:string
Inherited from
AbstractPickupWidgetManager.token
Methods
afterAssetsLoaded()
protectedafterAssetsLoaded(_assets):void
The carrier's assets are in the document and the mount element is already in place.
Nothing to do by default: a widget that is a custom element is picked up by the browser itself, whenever the script defines it. A carrier that builds its maps in a one-off scan overrides this — and may throw, because a map that cannot be built has to be visible to the storefront as a failure rather than as a silently empty frame.
Parameters
_assets
PickupWidgetAssetsState
Returns
void
Inherited from
AbstractPickupWidgetManager.afterAssetsLoaded
applyDescriptorAttributes()
protectedapplyDescriptorAttributes(element):void
Apply the descriptor's attributes to a freshly created element.
Parameters
element
HTMLElement
Returns
void
Inherited from
AbstractPickupWidgetManager.applyDescriptorAttributes
createElement()
protectedcreateElement():HTMLElement
Create the element the carrier's script turns into a map, with its attributes already set.
Attributes MUST be in place before the element enters the document: a custom element reads its configuration once, when it is connected, and a token set afterwards is ignored. That failure is invisible on the first open (the script is still loading, so the upgrade happens after the attribute lands) and appears only on the second — which is why it belongs here rather than in every storefront that renders a map.
Returns
HTMLElement
Overrides
AbstractPickupWidgetManager.createElement
destroy()
destroy():
void
Remove the widget and release everything it registered. Safe to call more than once.
Returns
void
Inherited from
AbstractPickupWidgetManager.destroy
mount()
mount(
container):Promise<void>
Mount the widget: the element enters the document FIRST, the carrier's assets follow.
That order is the whole difference between a map and an empty frame. A carrier whose widget is a plain element scans the document ONCE, when its script finishes loading, and never looks again — so an element inserted after that scan is never turned into a map, and nothing reports a failure. Waiting for the script before inserting made that the normal case; the custom-element carrier survived it only because a browser upgrades elements whenever they are defined, whenever that happens to be. Inserting first is correct for both.
A failure removes the element again. An empty box left in the checkout reads as a map that is still loading, and the storefront needs the rejection to fall back to point search.
Parameters
container
HTMLElement
Returns
Promise<void>
Inherited from
AbstractPickupWidgetManager.mount
subscribe()
protectedsubscribe():void
Start listening for the buyer's choice.
Returns
void
Overrides
AbstractPickupWidgetManager.subscribe
unsubscribe()
protectedunsubscribe():void
Stop listening and release anything registered globally.
Returns
void