Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 52 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,81 @@ on:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch: # Allow manual workflow execution

# Allow only one running workflow per branch
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
name: Test (Node.js ${{ matrix.node-version }})
runs-on: ubuntu-latest
timeout-minutes: 10

strategy:
fail-fast: false # Test all Node versions even if one fails
matrix:
node-version: [lts/*, current]

steps:
- name: Checkout
uses: actions/checkout@v5
with:
# For better coverage reports
fetch-depth: 0

- name: Use Node.js ${{ matrix.node-version }}
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v5
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Install dependencies
run: npm ci
run: npm ci --prefer-offline --no-audit

- name: Analyze JavaScript files
run: npm run-script lint

- name: Run test suite
run: |
npm test
npm run-script coverage
run: npm test

- name: Generate coverage report
run: npm run-script coverage

- name: Push coverage report
uses: coverallsapp/github-action@master
- name: Upload coverage report to Coveralls
if: matrix.node-version == 'lts/*' # Only upload once
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./coverage/lcov.info

jquery-compatibility:
name: jQuery Compatibility Tests
runs-on: ubuntu-latest
timeout-minutes: 10

strategy:
fail-fast: false
matrix:
jquery-version: ['3.7.1', '4.0.0-rc.1']

steps:
- name: Checkout
uses: actions/checkout@v5

- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: 'lts/*'
cache: 'npm'

- name: Install dependencies
run: npm ci --prefer-offline --no-audit

- name: Install jQuery ${{ matrix.jquery-version }}
run: npm install jquery@${{ matrix.jquery-version }}

- name: Run test suite with jQuery ${{ matrix.jquery-version }}
run: npm test
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ The most common use case would be:
```html
<p><a href="https://example.com/" title="example.com">Go to example site</a>

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

<script src="http://code.jquery.com/jquery-3.6.0.slim.min.js"></script>
<script src="http://code.jquery.com/jquery-4.0.0.slim.min.js"></script>
<script src="jquery.externalize.js"></script>
<script>
$('a[href$=".pdf"]').externalize({
Expand Down
7 changes: 4 additions & 3 deletions jquery.externalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* @see https://github.com/mrcgrtz/jquery-externalize
* @author Marc Görtz (https://marcgoertz.de/)
* @copyright 2011-2017
* @copyright 2011-2025
* @license MIT License
* @example $('a[href*="//"], a[rel="external"]').externalize();
* @param options Configuration object (see defaults in plugin function)
Expand All @@ -27,11 +27,12 @@ $.fn.externalize = function( options ) {

// save item and some useful information about it
var $this = $( this ),
isLink = $this.get( 0 ).nodeName === "A" || $this.get( 0 ).nodeName === "AREA",
nodeName = this.nodeName,
isLink = nodeName === "A" || nodeName === "AREA",
hasHref = $this.attr( "href" ),

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

// is this really a link with an "href" attribute?
if ( isLink && hasHref ) {
Expand Down
41 changes: 23 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
"eslint-config-jquery": "^3.0.0",
"eslint-formatter-pretty": "^7.0.0",
"globals": "^16.0.0",
"jquery": "^3.7.1",
"jquery": "4.0.0-rc.1",
"jsdom": "^27.0.0"
},
"peerDependencies": {
"jquery": "^1.7.0 || ^2 || ^3"
"jquery": "^1.7.0 || ^2 || ^3 || ^4"
}
}