Skip to content

Commit

Permalink
Fix: make sure it defaults to window.document
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgemanrubia committed Dec 5, 2024
1 parent ae7e0c7 commit bbb27f1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
11 changes: 4 additions & 7 deletions app/assets/javascripts/hotwire_spark.js
Original file line number Diff line number Diff line change
Expand Up @@ -3511,14 +3511,11 @@ var HotwireSpark = (function () {
}

class StimulusReloader {
static async reload() {
for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
params[_key] = arguments[_key];
}
return new StimulusReloader(...params).reload();
static async reload(filePattern) {
const document = await reloadHtmlDocument();
return new StimulusReloader(document, filePattern).reload();
}
constructor() {
let document = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window.document;
constructor(document) {
let filePattern = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : /./;
this.document = document;
this.filePattern = filePattern;
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/hotwire_spark.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/assets/javascripts/hotwire_spark.min.js.map

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions app/javascript/hotwire_spark/reloaders/stimulus_reloader.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Application } from "@hotwired/stimulus"
import { log } from "../logger.js"
import { cacheBustedUrl } from "../helpers.js"
import { cacheBustedUrl, reloadHtmlDocument } from "../helpers.js"

export class StimulusReloader {
static async reload(...params) {
return new StimulusReloader(...params).reload()
static async reload(filePattern) {
const document = await reloadHtmlDocument()
return new StimulusReloader(document, filePattern).reload()
}

constructor(document = window.document, filePattern = /./) {
constructor(document, filePattern = /./) {
this.document = document
this.filePattern = filePattern
this.application = window.Stimulus || Application.start()
Expand Down

0 comments on commit bbb27f1

Please sign in to comment.