@@ -2,10 +2,10 @@ import { HTMLElement } from './HTMLElement';
2
2
import { HTMLVideoElement } from './HTMLVideoElement' ;
3
3
import { HTMLImageElement } from './HTMLImageElement' ;
4
4
import { HTMLCanvasElement } from './HTMLCanvasElement' ;
5
- import { SVGElement , SVGCircleElement , SVGRectElement , SVGGElement , SVGPathElement } from './svg ' ;
5
+ import { HTMLDivElement } from './HTMLDivElement ' ;
6
6
import { Text } from './Text' ;
7
7
import { Canvas } from '@nativescript/canvas' ;
8
- import { Frame } from '@nativescript/core' ;
8
+ import { Frame , StackLayout } from '@nativescript/core' ;
9
9
import { Node } from './Node' ;
10
10
import { Element } from './Element' ;
11
11
@@ -29,6 +29,8 @@ export class Document extends Node {
29
29
30
30
createElement ( tagName : string ) {
31
31
switch ( ( tagName || '' ) . toLowerCase ( ) ) {
32
+ case 'div' :
33
+ return new HTMLDivElement ( ) ;
32
34
case 'video' :
33
35
return new HTMLVideoElement ( ) ;
34
36
case 'img' :
@@ -38,16 +40,16 @@ export class Document extends Node {
38
40
case 'iframe' :
39
41
// Return nothing to keep firebase working.
40
42
return null ;
41
- // case 'svg':
42
- // return new SVGElement();
43
- // case 'rect':
44
- // return new SVGRectElement();
45
- // case 'circle':
46
- // return new SVGCircleElement();
47
- // case 'g':
48
- // return new SVGGElement();
49
- // case 'path':
50
- // return new SVGPathElement();
43
+ case 'svg' :
44
+ return new SVGElement ( ) ;
45
+ case 'rect' :
46
+ return new SVGRectElement ( ) ;
47
+ case 'circle' :
48
+ return new SVGCircleElement ( ) ;
49
+ case 'g' :
50
+ return new SVGGElement ( ) ;
51
+ case 'path' :
52
+ return new SVGPathElement ( ) ;
51
53
default :
52
54
return new Element ( tagName ) ;
53
55
}
@@ -75,6 +77,10 @@ export class Document extends Node {
75
77
const canvas = new HTMLCanvasElement ( ) ;
76
78
canvas . nativeElement = nativeElement ;
77
79
return canvas ;
80
+ } else if ( nativeElement instanceof StackLayout ) {
81
+ const div = new HTMLDivElement ( ) ;
82
+ div . nativeElement = nativeElement ;
83
+ return div ;
78
84
}
79
85
const element = new HTMLElement ( ) ;
80
86
element . nativeElement = nativeElement ;
@@ -93,23 +99,25 @@ export class Document extends Node {
93
99
}
94
100
95
101
//@ts -ignore
96
- set documentElement ( value ) { }
102
+ set documentElement ( value ) {
103
+ }
97
104
98
105
querySelectorAll ( selector ) {
99
- return ( this as any ) . _instance ?. querySelectorAll ?.( selector ) ?? [ ] ;
106
+ return [ ] ;
107
+ //return (this as any)._instance?.querySelectorAll?.(selector) ?? [];
100
108
}
101
109
102
110
querySelector ( selector ) {
103
- const ret = ( this as any ) . _instance ?. querySelectorAll ?.( selector ) ;
104
- let element = ret ?. [ 0 ] ?? null ;
105
- if ( ret === undefined ) {
106
- const items = ( this as any ) . _instance . getElementsByTagName ( selector ) ;
107
- element = items [ 0 ] ;
108
- }
109
-
110
- if ( element ) {
111
- return new ( Element as any ) ( element ) ;
112
- }
111
+ // const ret = (this as any)._instance?.querySelectorAll?.(selector);
112
+ // let element = ret?.[0] ?? null;
113
+ // if (ret === undefined) {
114
+ // const items = (this as any)._instance.getElementsByTagName(selector);
115
+ // element = items[0];
116
+ // }
117
+ //
118
+ // if (element) {
119
+ // return new (Element as any)(element);
120
+ // }
113
121
return null ;
114
122
}
115
123
}
0 commit comments