File tree 3 files changed +16
-3
lines changed
3 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import {is} from '../utils';
11
11
import type { Node } from './Node' ;
12
12
import type { ShapeProps } from './Shape' ;
13
13
import { Shape } from './Shape' ;
14
- import { TxtLeaf } from './TxtLeaf' ;
14
+ import { TXT_TYPE , TxtLeaf } from './TxtLeaf' ;
15
15
import type { ComponentChildren } from './types' ;
16
16
17
17
type TxtChildren = string | Node | ( string | Node ) [ ] ;
@@ -24,6 +24,8 @@ export interface TxtProps extends ShapeProps {
24
24
25
25
@nodeName ( 'Txt' )
26
26
export class Txt extends Shape {
27
+ public readonly [ TXT_TYPE ] = true ;
28
+
27
29
/**
28
30
* Create a bold text node.
29
31
*
Original file line number Diff line number Diff line change @@ -15,6 +15,8 @@ export interface TxtLeafProps extends ShapeProps {
15
15
text ?: SignalValue < string > ;
16
16
}
17
17
18
+ export const TXT_TYPE = Symbol ( 'Txt' ) ;
19
+
18
20
@nodeName ( 'TxtLeaf' )
19
21
export class TxtLeaf extends Shape {
20
22
@lazy ( ( ) => {
@@ -43,7 +45,15 @@ export class TxtLeaf extends Shape {
43
45
@computed ( )
44
46
protected parentTxt ( ) {
45
47
const parent = this . parent ( ) ;
46
- return parent ?. constructor . name === 'Txt' ? parent : null ;
48
+ if ( ! parent ) {
49
+ return null ;
50
+ }
51
+
52
+ if ( ! ( TXT_TYPE in parent ) ) {
53
+ return null ;
54
+ }
55
+
56
+ return parent ;
47
57
}
48
58
49
59
protected override async draw ( context : CanvasRenderingContext2D ) {
Original file line number Diff line number Diff line change @@ -21,7 +21,8 @@ function isClassComponent(
21
21
return ! ! fn . prototype ?. isClass ;
22
22
}
23
23
24
- export const Fragment = Symbol . for ( '@revideo/2d/fragment' ) ;
24
+ export const Fragment : FunctionComponent = ( { children} ) => children ;
25
+
25
26
export function jsx (
26
27
type : NodeConstructor | FunctionComponent | typeof Fragment ,
27
28
config : JSXProps ,
You can’t perform that action at this time.
0 commit comments