Skip to content

Commit

Permalink
Add skipinit modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
bencroker committed Feb 22, 2025
1 parent cb6dcba commit 2e0e5fb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Each tagged version of Datastar is accompanied by a release note. Read the [rele
### Added

- Added the ability for checkbox input elements to set bound signals to an array of values by predefining the signal as an array ([#664](https://github.com/starfederation/datastar/issues/674)).
- Added the `__skipinit` modifier to the `data-on-signals-change` attribute that prevents the expression being called when the attribute is first applied ([#682](https://github.com/starfederation/datastar/issues/682)).

### Changed

Expand All @@ -19,5 +20,4 @@ Each tagged version of Datastar is accompanied by a release note. Read the [rele
### Fixed

- Fixed a bug in which `datastar-remove-fragments` events were not having any effect ([#664](https://github.com/starfederation/datastar/issues/664)).
- Fixed a bug in which `datastarNaN` could be used as an auto-generated element ID ([#679](https://github.com/starfederation/datastar/issues/679)).
- Fixed a bug in which the expression passed into `data-on-signals-change` was being called each time the attribute was evaluated ([#682](https://github.com/starfederation/datastar/issues/682)).
- Fixed a bug in which `datastarNaN` could be used as an auto-generated element ID ([#679](https://github.com/starfederation/datastar/issues/679)).
4 changes: 4 additions & 0 deletions library/src/plugins/official/dom/attributes/on.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ export const On: AttributePlugin = {

if (key.startsWith(SIGNALS_CHANGE_PREFIX)) {
if (key === SIGNALS_CHANGE_PREFIX) {
const skipinit = mods.has('skipinit')
if (!skipinit) {
callback()
}
const signalFn = (event: CustomEvent<DatastarSignalEvent>) =>
callback(event)
document.addEventListener(DATASTAR_SIGNAL_EVENT, signalFn)
Expand Down

0 comments on commit 2e0e5fb

Please sign in to comment.