Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
falsandtru committed Feb 13, 2024
1 parent 3821e85 commit eae11e7
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions gh-pages/docs/apis/pjax/config/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Set a dictionary object having has/get/set/delete methods of Map to pass the doc

## fetch: {...} = ...

### rewrite?: (url: string, method: string, headers: Headers, timeout: number, body: FormData | null, cache?: Document) => XMLHttpRequest | undefined
### rewrite?: (url: string, method: string, headers: Headers, timeout: number, body: FormData | null, memory?: Document) => XMLHttpRequest | undefined

Rewrite the XHR object, or replace it with another or fake.

Expand All @@ -58,7 +58,7 @@ Wait for the specified milliseconds after sending a request.

## update: {...} = ...

### rewrite?: (url: string, document: Document, area: string, cache?: Document) => void
### rewrite?: (url: string, document: Document, area: string, memory?: Document) => void

Rewrite the source document object.
If you use the sequence option, you should use only it instead of this.
Expand Down
4 changes: 2 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ export interface Config {
readonly replace?: string;
readonly memory?: Dict<string, Document>;
readonly fetch?: {
readonly rewrite?: (url: string, method: string, headers: Headers, timeout: number, body: FormData | null, cache?: Document) => XMLHttpRequest | undefined;
readonly rewrite?: (url: string, method: string, headers: Headers, timeout: number, body: FormData | null, memory?: Document) => XMLHttpRequest | undefined;
readonly headers?: Headers;
readonly timeout?: number;
readonly wait?: number;
};
readonly update?: {
readonly rewrite?: (url: string, document: Document, area: string, cache?: Document) => void;
readonly rewrite?: (url: string, document: Document, area: string, memory?: Document) => void;
readonly head?: string;
readonly css?: boolean;
readonly script?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/layer/domain/router/module/fetch/xhr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function xhr(
body: FormData | null,
timeout: number,
cancellation: Cancellee<Error>,
rewrite: (url: string, method: string, headers: Headers, timeout: number, body: FormData | null, cache?: Document | undefined) => XMLHttpRequest | undefined = noop,
rewrite: (url: string, method: string, headers: Headers, timeout: number, body: FormData | null, memory?: Document | undefined) => XMLHttpRequest | undefined = noop,
memory?: Document,
): AtomicPromise<Either<Error, Response>> {
return new AtomicPromise<Either<Error, Response>>(resolve => {
Expand Down
4 changes: 2 additions & 2 deletions test/integration/config/update.rewrite.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ describe('Integration: Config', function () {
new Pjax({
memory: new Cache(100),
update: {
rewrite(url, doc, area, cache) {
rewrite(url, doc, area, memory) {
switch (url.split('/').at(-1)) {
case '2.html':
cache && doc.querySelector(area)?.replaceWith(cache.querySelector(area)!.cloneNode(true));
memory && doc.querySelector(area)?.replaceWith(memory.querySelector(area)!.cloneNode(true));
}
},
},
Expand Down

0 comments on commit eae11e7

Please sign in to comment.