Skip to content
This repository has been archived by the owner on Dec 14, 2019. It is now read-only.

Commit

Permalink
Merge pull request #8 from codewithkyle/develop
Browse files Browse the repository at this point in the history
Fixes script import bug when documents don't match
  • Loading branch information
codewithkyle committed Apr 16, 2019
2 parents 04c2f8e + 99d3faf commit 1185e0c
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 32 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 2.1.1 - 2019-04-16

### Fixes

- Fixes: script loading bug when the current `document` and the incoming `document` don't match

# 2.1.0 - 2019-04-15

### Adds:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@codewithkyle/pjax",
"version": "2.1.0",
"version": "2.1.1",
"description": "Turns any website into a SPA using Fetch and link prefetching.",
"keywords": [
"pjax",
Expand Down
20 changes: 7 additions & 13 deletions pjax.js

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

2 changes: 1 addition & 1 deletion pjax.js.map

Large diffs are not rendered by default.

26 changes: 9 additions & 17 deletions src/pjax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import PJAX from './global';

export default class Pjax{

public static VERSION:string = '2.1.0';
public static VERSION:string = '2.1.1';

public options: PJAX.IOptions;
private _cache: PJAX.ICacheObject;
Expand Down Expand Up @@ -368,6 +368,14 @@ export default class Pjax{
this.lastChance(this._response.url);
return;
}

if(this.options.importScripts){
this.handleScripts(tempDocument);
}

if(this.options.importCSS){
this.handleCSS(tempDocument);
}

// Check if Pjax needs to wait for the continue event
if(!this.options.customTransitions){
Expand Down Expand Up @@ -424,14 +432,6 @@ export default class Pjax{

StateManager.doReplace(window.location.href, document.title);

if(this.options.importScripts){
this.handleScripts(this._cache.document);
}

if(this.options.importCSS){
this.handleCSS(this._cache.document);
}

// Build the selector swapping queue
this.switchSelectors(this.options.selectors, this._cache.document);
}
Expand Down Expand Up @@ -505,14 +505,6 @@ export default class Pjax{
clearActive();

StateManager.doReplace(window.location.href, document.title);

if(this.options.importScripts){
this.handleScripts(tempDocument);
}

if(this.options.importCSS){
this.handleCSS(tempDocument);
}

// Swap the current page with the new page
this.switchSelectors(this.options.selectors, tempDocument);
Expand Down

0 comments on commit 1185e0c

Please sign in to comment.