Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
06a0a5bb
Commit
06a0a5bb
authored
Mar 31, 2023
by
Alejandro Celaya
Committed by
Alejandro Celaya
Apr 10, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate url-from-link-tag module to TypeScript
parent
23cda6f7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
9 deletions
+10
-9
url-from-link-tag.ts
src/annotator/config/url-from-link-tag.ts
+10
-9
No files found.
src/annotator/config/url-from-link-tag.
j
s
→
src/annotator/config/url-from-link-tag.
t
s
View file @
06a0a5bb
...
...
@@ -6,18 +6,19 @@
* in a separate JavaScript realm (eg. in the browser extension), and thus can share information
* with the annotator code via the DOM but not JS globals.
*
* @param {Window} window_
* @param {string} rel - The `rel` attribute to match
* @param {'javascript'|'html'} type - Type of resource that the link refers to
* @param rel - The `rel` attribute to match
* @param type - Type of resource that the link refers to
* @throws {Error} - If there's no link with the `rel` indicated, or the first
* matching link has no `href`
*/
export
function
urlFromLinkTag
(
window_
,
rel
,
type
)
{
const
link
=
/** @type {HTMLLinkElement} */
(
window_
.
document
.
querySelector
(
`link[type="application/annotator+
${
type
}
"][rel="
${
rel
}
"]`
)
);
export
function
urlFromLinkTag
(
window_
:
Window
,
rel
:
string
,
type
:
'javascript'
|
'html'
)
{
const
link
=
window_
.
document
.
querySelector
(
`link[type="application/annotator+
${
type
}
"][rel="
${
rel
}
"]`
)
as
HTMLLinkElement
|
undefined
;
if
(
!
link
)
{
throw
new
Error
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment