Skip to content

Commit b32ea66

Browse files
committed
Prepare for jQuery 4.
1 parent eec510b commit b32ea66

File tree

5 files changed

+71
-24
lines changed

5 files changed

+71
-24
lines changed

.github/workflows/test.yml

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,81 @@ on:
55
branches: [ main ]
66
pull_request:
77
branches: [ main ]
8+
workflow_dispatch: # Allow manual workflow execution
9+
10+
# Allow only one running workflow per branch
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
814

915
jobs:
1016
test:
17+
name: Test (Node.js ${{ matrix.node-version }})
1118
runs-on: ubuntu-latest
19+
timeout-minutes: 10
1220

1321
strategy:
22+
fail-fast: false # Test all Node versions even if one fails
1423
matrix:
15-
node-version: [lts/*, current]
24+
node-version: [lts/hydrogen, lts/iron, lts/*, current]
1625

1726
steps:
1827
- name: Checkout
1928
uses: actions/checkout@v5
29+
with:
30+
# For better coverage reports
31+
fetch-depth: 0
2032

21-
- name: Use Node.js ${{ matrix.node-version }}
33+
- name: Setup Node.js ${{ matrix.node-version }}
2234
uses: actions/setup-node@v5
2335
with:
2436
node-version: ${{ matrix.node-version }}
37+
cache: 'npm'
2538

2639
- name: Install dependencies
27-
run: npm ci
40+
run: npm ci --prefer-offline --no-audit
2841

2942
- name: Analyze JavaScript files
3043
run: npm run-script lint
3144

3245
- name: Run test suite
33-
run: |
34-
npm test
35-
npm run-script coverage
46+
run: npm test
47+
48+
- name: Generate coverage report
49+
run: npm run-script coverage
3650

37-
- name: Push coverage report
38-
uses: coverallsapp/github-action@master
51+
- name: Upload coverage report to Coveralls
52+
if: matrix.node-version == 'lts/*' # Only upload once
53+
uses: coverallsapp/github-action@v2
3954
with:
4055
github-token: ${{ secrets.GITHUB_TOKEN }}
56+
path-to-lcov: ./coverage/lcov.info
57+
58+
jquery-compatibility:
59+
name: jQuery Compatibility Tests
60+
runs-on: ubuntu-latest
61+
timeout-minutes: 10
62+
63+
strategy:
64+
fail-fast: false
65+
matrix:
66+
jquery-version: ['3.7.1', '4.0.0-rc.1']
67+
68+
steps:
69+
- name: Checkout
70+
uses: actions/checkout@v5
71+
72+
- name: Setup Node.js
73+
uses: actions/setup-node@v5
74+
with:
75+
node-version: 'lts/*'
76+
cache: 'npm'
77+
78+
- name: Install dependencies
79+
run: npm ci --prefer-offline --no-audit
80+
81+
- name: Install jQuery ${{ matrix.jquery-version }}
82+
run: npm install jquery@${{ matrix.jquery-version }}
83+
84+
- name: Run test suite with jQuery ${{ matrix.jquery-version }}
85+
run: npm test

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ The most common use case would be:
4545
```html
4646
<p><a href="https://example.com/" title="example.com">Go to example site</a>
4747

48-
<script src="http://code.jquery.com/jquery-3.6.0.slim.min.js"></script>
48+
<script src="http://code.jquery.com/jquery-4.0.0.slim.min.js"></script>
4949
<script src="jquery.externalize.js"></script>
5050
<script>
5151
$('a[href*="//"]').externalize();
@@ -63,7 +63,7 @@ Another use case: Opening PDF files in a new window.
6363
```html
6464
<p><a href="/download/sample.pdf">Download PDF</a>
6565

66-
<script src="http://code.jquery.com/jquery-3.6.0.slim.min.js"></script>
66+
<script src="http://code.jquery.com/jquery-4.0.0.slim.min.js"></script>
6767
<script src="jquery.externalize.js"></script>
6868
<script>
6969
$('a[href$=".pdf"]').externalize({

jquery.externalize.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* @see https://github.com/mrcgrtz/jquery-externalize
77
* @author Marc Görtz (https://marcgoertz.de/)
8-
* @copyright 2011-2017
8+
* @copyright 2011-2025
99
* @license MIT License
1010
* @example $('a[href*="//"], a[rel="external"]').externalize();
1111
* @param options Configuration object (see defaults in plugin function)
@@ -27,11 +27,12 @@ $.fn.externalize = function( options ) {
2727

2828
// save item and some useful information about it
2929
var $this = $( this ),
30-
isLink = $this.get( 0 ).nodeName === "A" || $this.get( 0 ).nodeName === "AREA",
30+
nodeName = this.nodeName,
31+
isLink = nodeName === "A" || nodeName === "AREA",
3132
hasHref = $this.attr( "href" ),
3233

3334
// if any options were supplied, apply them to the configuration object
34-
config = $.extend( defaults, options );
35+
config = $.extend( {}, defaults, options );
3536

3637
// is this really a link with an "href" attribute?
3738
if ( isLink && hasHref ) {

package-lock.json

Lines changed: 10 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030
"eslint-config-jquery": "^3.0.0",
3131
"eslint-formatter-pretty": "^5.0.0",
3232
"globals": "^16.0.0",
33-
"jquery": "^3.7.1",
33+
"jquery": "4.0.0-rc.1",
3434
"jsdom": "^26.0.0"
3535
},
3636
"peerDependencies": {
37-
"jquery": "^1.7.0 || ^2 || ^3"
37+
"jquery": "^1.7.0 || ^2 || ^3 || ^4"
3838
}
3939
}

0 commit comments

Comments
 (0)