Skip to content

Commit

Permalink
fix: lazy check for jQuery on legacy widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey committed Oct 24, 2023
1 parent a6434f8 commit d7f7f07
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/happy-donuts-yell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"marko": patch
---

Lazily check for global jQuery when patching legacy components.
4 changes: 2 additions & 2 deletions packages/marko/src/runtime/components/legacy/jquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ var ready = require("./ready");
var idRegExp = /^#(\S+)( .*)?/;

exports.patchComponent = function (jQuery, proto, delayThrow) {
if (!(jQuery || (jQuery = window.$)) && !delayThrow) {
if (!jQuery && !delayThrow) {

Check warning on line 6 in packages/marko/src/runtime/components/legacy/jquery.js

View check run for this annotation

Codecov / codecov/patch

packages/marko/src/runtime/components/legacy/jquery.js#L6

Added line #L6 was not covered by tests
throw new Error("jQuery not found");
}

(proto || require("../Component").prototype).$ = function jqueryProxy(arg) {
var args = arguments;
var self = this;

if (!jQuery) {
if (!(jQuery || (jQuery = window.$))) {

Check warning on line 14 in packages/marko/src/runtime/components/legacy/jquery.js

View check run for this annotation

Codecov / codecov/patch

packages/marko/src/runtime/components/legacy/jquery.js#L14

Added line #L14 was not covered by tests
throw new Error("jQuery not found");
}

Expand Down

0 comments on commit d7f7f07

Please sign in to comment.