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
5bd41a44
Commit
5bd41a44
authored
Feb 02, 2024
by
Robert Knight
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make `PreactContainer` render function more flexible
Allow components to render `null` or other non-element values.
parent
53d1ecb0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
preact-container.ts
src/annotator/util/preact-container.ts
+3
-3
No files found.
src/annotator/util/preact-container.ts
View file @
5bd41a44
import
type
{
JSX
}
from
'preact'
;
import
type
{
ComponentChild
}
from
'preact'
;
import
{
render
}
from
'preact'
;
import
type
{
Destroyable
}
from
'../../types/annotator'
;
...
...
@@ -19,7 +19,7 @@ import { createShadowRoot } from './shadow-root';
export
class
PreactContainer
implements
Destroyable
{
private
_element
:
HTMLElement
;
private
_shadowRoot
:
ShadowRoot
;
private
_render
:
()
=>
JSX
.
Element
;
private
_render
:
()
=>
ComponentChild
;
/**
* Create a new `<hypothesis-{name}>` container element.
...
...
@@ -30,7 +30,7 @@ export class PreactContainer implements Destroyable {
* @param name - Suffix for the element
* @param render - Callback that renders the root JSX element for this container
*/
constructor
(
name
:
string
,
render
:
()
=>
JSX
.
Element
)
{
constructor
(
name
:
string
,
render
:
()
=>
ComponentChild
)
{
const
tag
=
`hypothesis-
${
name
}
`
;
this
.
_element
=
document
.
createElement
(
tag
);
this
.
_shadowRoot
=
createShadowRoot
(
this
.
_element
);
...
...
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