-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): CHECKOUT-3012 Avoid loading the same script twice
- Loading branch information
Showing
6 changed files
with
48 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import ScriptLoader from './script-loader'; | ||
|
||
export default function createScriptLoader(): ScriptLoader { | ||
return new ScriptLoader(document); | ||
return new ScriptLoader(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import getScriptLoader from './get-script-loader'; | ||
import ScriptLoader from './script-loader'; | ||
|
||
describe('getScriptLoader()', () => { | ||
it('returns same `ScriptLoader` instance', () => { | ||
const loader = getScriptLoader(); | ||
const loader2 = getScriptLoader(); | ||
|
||
expect(loader).toBe(loader2); | ||
expect(loader).toBeInstanceOf(ScriptLoader); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import ScriptLoader from './script-loader'; | ||
import createScriptLoader from './create-script-loader'; | ||
|
||
let instance: ScriptLoader; | ||
|
||
export default function getScriptLoader(): ScriptLoader { | ||
if (!instance) { | ||
instance = createScriptLoader(); | ||
} | ||
|
||
return instance; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { default as ScriptLoader } from './script-loader'; | ||
export { default as createScriptLoader } from './create-script-loader'; | ||
export { default as getScriptLoader } from './get-script-loader'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters