Skip to content

Commit

Permalink
Update comments regarding DOMContentLoaded listeners
Browse files Browse the repository at this point in the history
We only bind to `pageshow` now (slight edit) since: ae75de1
  • Loading branch information
colinrotherham committed Jun 8, 2023
1 parent 14541c5 commit 0f0457f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,13 @@ CharacterCount.prototype.init = function () {
this.bindChangeEvents()

// When the page is restored after navigating 'back' in some browsers the
// state of the character count is not restored until *after* the
// DOMContentLoaded event is fired, so we need to manually update it after the
// pageshow event.
// state of form controls is not restored until *after* the DOMContentLoaded
// event is fired, so we need to sync after the pageshow event.
window.addEventListener('pageshow', this.updateCountMessage.bind(this))

// Although we've set up handlers to sync state on the pageshow event, init
// could be called after those events have fired, for example if they are
// added to the page dynamically, so update now too.
this.updateCountMessage()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ Checkboxes.prototype.init = function () {
// event is fired, so we need to sync after the pageshow event.
window.addEventListener('pageshow', this.syncAllConditionalReveals.bind(this))

// Although we've set up handlers to sync state on the pageshow or
// DOMContentLoaded event, init could be called after those events have fired,
// for example if they are added to the page dynamically, so sync now too.
// Although we've set up handlers to sync state on the pageshow event, init
// could be called after those events have fired, for example if they are
// added to the page dynamically, so sync now too.
this.syncAllConditionalReveals()

// Handle events
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ Radios.prototype.init = function () {
// event is fired, so we need to sync after the pageshow event.
window.addEventListener('pageshow', this.syncAllConditionalReveals.bind(this))

// Although we've set up handlers to sync state on the pageshow or
// DOMContentLoaded event, init could be called after those events have fired,
// for example if they are added to the page dynamically, so sync now too.
// Although we've set up handlers to sync state on the pageshow event, init
// could be called after those events have fired, for example if they are
// added to the page dynamically, so sync now too.
this.syncAllConditionalReveals()

// Handle events
Expand Down

0 comments on commit 0f0457f

Please sign in to comment.