-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: remove inline script source-url (#2850)
- Loading branch information
1 parent
b2d2c11
commit a826cf5
Showing
3 changed files
with
29 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@qiankunjs/shared': patch | ||
--- | ||
|
||
fix: remove inline script source-url |
23 changes: 23 additions & 0 deletions
23
packages/shared/src/assets-transpilers/__tests__/script.test.ts
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,23 @@ | ||
import { expect, it, vi } from 'vitest'; | ||
import transpileScript from '../script'; | ||
|
||
it('inline script not include sourceURL', () => { | ||
class MockSandbox { | ||
makeEvaluateFactory(source: string, sourceURL?: string): string { | ||
return ''; | ||
} | ||
} | ||
|
||
const code = 'console.log("hello world")'; | ||
const publicPath = 'http://localhost:8000'; | ||
const scriptElement = document.createElement('script'); | ||
scriptElement.innerHTML = code; | ||
const sandboxInstance = new MockSandbox(); | ||
const makeEvaluateFactorySpy = vi.spyOn(sandboxInstance, 'makeEvaluateFactory'); | ||
transpileScript(scriptElement, publicPath, { | ||
fetch: window.fetch, | ||
rawNode: scriptElement, | ||
sandbox: sandboxInstance, | ||
}); | ||
expect(makeEvaluateFactorySpy).toHaveBeenCalledWith(code); | ||
}); |
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