@gluonjs/core


@gluonjs/core / src / applyGluonElementHotUpdate

Function: applyGluonElementHotUpdate()

applyGluonElementHotUpdate<Constructor>(tagName, next, options?): GluonElementHotUpdateResult<Constructor>

Registers the first Custom Element constructor and patches its compatible prototype on later Vite evaluations. Application code should use defineElement(); this entry point belongs to the official Vite integration.

Type Parameters

Constructor

Constructor extends GluonElementClass<GluonElement<any>>

Parameters

tagName

`${string}-${string}`

next

Constructor

options?

DefineElementOptions = {}

Returns

GluonElementHotUpdateResult<Constructor>

Example

Let the official Vite integration register the first element constructor or patch a compatible replacement while preserving existing instances:

ts
import {
  GluonElement,
  applyGluonElementHotUpdate,
  html,
  type GluonElementHotUpdateResult,
} from '@gluonjs/core';

class ProductCard extends GluonElement {
  protected render() { return html`<article>Updated product</article>`; }
}
const update: GluonElementHotUpdateResult<typeof ProductCard> =
  applyGluonElementHotUpdate('product-card', ProductCard);
console.log(update.compatible, update.reason);