-
Notifications
You must be signed in to change notification settings - Fork 73
Replace jQuery 1 with jQuery 3 as global $ #4333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
60ae2b5
bd1e639
6c23dec
b96b669
25ff8cc
ac6593a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| //= require jquery | ||
| //= require jquery3 | ||
| //= require rails-ujs |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| //= require jquery | ||
| //= require vendor/colorbox | ||
| //= require jquery3 | ||
| //= require rails-ujs | ||
| //= require vendor/jquery.colorbox-min.js |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| /** | ||
| * Spoiler alert: if you're reading this, it's already too late. jQuery 1 is loaded. | ||
| * | ||
| * Colorbox 1.6.4 is incompatible with jQuery 3 (uses .live, .bind, $.isFunction, $.support). It | ||
| * must run on jQuery 1.12.4. | ||
| * | ||
| * This file loads jQuery 1.12.4 first, then colorbox (which attaches to it), then exports colorbox | ||
| * to the global scope as window.colorbox. After this file, provider.js loads jquery3 which | ||
| * overwrites the global $ and jQuery with jQuery 3.7.0. | ||
| * | ||
| * The loading order in provider.js is critical: | ||
| * 1. vendor/colorbox | ||
| * 2. jquery3 | ||
| * 3. rails-ujs | ||
| * | ||
| * All colorbox calls must use window.colorbox, not $.colorbox. | ||
| * | ||
| * jQuery.colorbox is both a callable function and an object with methods (.close, .resize). | ||
| * .bind(jQuery) fixes the "this" context so colorbox works when called as window.colorbox(). | ||
| * Object.assign copies .close, .resize, etc. onto the bound function because .bind() creates | ||
| * a bare function without the original's custom properties. | ||
| */ | ||
|
|
||
| //= require jquery | ||
| //= require vendor/jquery.colorbox-min.js | ||
|
|
||
| window.colorbox = Object.assign(jQuery.colorbox.bind(jQuery), jQuery.colorbox); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
| import $ from 'jquery' | ||
| import 'jquery-ui/ui/widgets/tabs' | ||
|
|
||
| document.addEventListener('DOMContentLoaded', () => { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,7 @@ | ||
| // This is Developer Portal stats | ||
|
|
||
| import $ from 'jquery' | ||
| // Developer Portal stats. Loaded by lib/developer_portal/app/views/developer_portal/stats/_chart.html.liquid. | ||
| // jQuery comes from the tenant's template (e.g. cdn_asset or essential_assets). | ||
| // jQuery UI datepicker is bundled by webpack via Stats/lib/menu.js and attaches to the tenant's jQuery. | ||
|
Comment on lines
+1
to
+3
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand this part. Before, it always took jequey1, right? and now it will take whatever the admin added to the template. So we moved from a fixed value to a dynamic value in the hands of the admin. IS this not a breaking change? Don't you think we have templates in SaaS which doesn't load Jquery or load a different version? |
||
|
|
||
| import { statsApplication } from 'Stats/buyer/stats_application' | ||
|
|
||
| window.$ = $ | ||
| window.Stats = { statsApplication } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,8 @@ interface ExpirationItem { | |
| period: number; // In days | ||
| } | ||
|
|
||
| const a; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Assets don't compile due to this. |
||
|
|
||
| const collection: ExpirationItem[] = [ | ||
| { id: '7', label: '7 days', period: 7 }, | ||
| { id: '30', label: '30 days', period: 30 }, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.