-
Notifications
You must be signed in to change notification settings - Fork 444
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bc02fa0
commit 9e2b964
Showing
4 changed files
with
81 additions
and
62 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,58 +1,41 @@ | ||
import { getUrl } from './worker-exec'; | ||
import { commaSplit } from './worker-constants'; | ||
import { getEnv } from './worker-environment'; | ||
import { getInstanceStateValue, setInstanceStateValue } from './worker-state'; | ||
import { getter, setter } from './worker-proxy'; | ||
import type { Node } from './worker-node'; | ||
import { setInstanceStateValue } from './worker-state'; | ||
import { setter } from './worker-proxy'; | ||
import { resolveToUrl } from './worker-exec'; | ||
import { StateProp } from '../types'; | ||
|
||
export const HTMLAnchorDescriptorMap: PropertyDescriptorMap & ThisType<Node> = { | ||
hash: { | ||
get() { | ||
return getUrl(this).hash; | ||
}, | ||
}, | ||
host: { | ||
get() { | ||
return getUrl(this).host; | ||
}, | ||
}, | ||
hostname: { | ||
get() { | ||
return getUrl(this).hostname; | ||
}, | ||
}, | ||
href: { | ||
get() { | ||
return getUrl(this).href; | ||
}, | ||
set(href) { | ||
href = href + ''; | ||
setInstanceStateValue(this, StateProp.url, href); | ||
setter(this, ['href'], href); | ||
}, | ||
}, | ||
origin: { | ||
get() { | ||
return getUrl(this).origin; | ||
}, | ||
}, | ||
pathname: { | ||
get() { | ||
return getUrl(this).pathname; | ||
}, | ||
}, | ||
port: { | ||
get() { | ||
return getUrl(this).port; | ||
}, | ||
}, | ||
protocol: { | ||
get() { | ||
return getUrl(this).protocol; | ||
export const HTMLAnchorDescriptorMap: PropertyDescriptorMap & ThisType<Node> = {}; | ||
|
||
const anchorProps = commaSplit('hash,host,hostname,href,origin,pathname,port,protocol,search'); | ||
|
||
anchorProps.map((anchorProp) => { | ||
HTMLAnchorDescriptorMap[anchorProp] = { | ||
get(this: any) { | ||
let env = getEnv(this); | ||
let value = getInstanceStateValue(this, StateProp.url); | ||
let href: string; | ||
|
||
if (typeof value !== 'string') { | ||
href = getter(this, ['href']); | ||
setInstanceStateValue(this, StateProp.url, href); | ||
value = (new URL(href) as any)[anchorProp]; | ||
} | ||
|
||
return (resolveToUrl(env, value) as any)[anchorProp]; | ||
}, | ||
}, | ||
search: { | ||
get() { | ||
return getUrl(this).search; | ||
|
||
set(this: any, value) { | ||
let env = getEnv(this); | ||
let href = getInstanceStateValue(this, StateProp.url); | ||
let url: any = resolveToUrl(env, href); | ||
|
||
url[anchorProp] = new URL(value + '', url.href); | ||
|
||
setInstanceStateValue(this, StateProp.url, url.href); | ||
|
||
setter(this, ['href'], url.href); | ||
}, | ||
}, | ||
}; | ||
}; | ||
}); |
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
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
9e2b964
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: