@tarojs/plugin-platform-harmony-ets 4.0.0-beta.3 → 4.0.0-beta.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/apis/base/system.ts +53 -20
- package/dist/apis/canvas/index.ts +10 -1
- package/dist/apis/framework/index.ts +1 -5
- package/dist/apis/index.ts +27 -12
- package/dist/apis/network/request.ts +5 -5
- package/dist/apis/route/index.ts +15 -0
- package/dist/apis/storage/index.ts +205 -63
- package/dist/apis/ui/animation/animation.ts +2 -1
- package/dist/apis/utils/index.ts +1 -1
- package/dist/apis/wxml/IntersectionObserver.ts +18 -10
- package/dist/apis/wxml/index.ts +2 -0
- package/dist/components-harmony-ets/button.ets +50 -78
- package/dist/components-harmony-ets/canvas.ets +51 -0
- package/dist/components-harmony-ets/checkbox.ets +23 -209
- package/dist/components-harmony-ets/form.ets +44 -158
- package/dist/components-harmony-ets/icon.ets +38 -83
- package/dist/components-harmony-ets/image.ets +29 -78
- package/dist/components-harmony-ets/index.ets +53 -0
- package/dist/components-harmony-ets/innerHtml.ets +11 -6
- package/dist/components-harmony-ets/input.ets +11 -67
- package/dist/components-harmony-ets/label.ets +58 -172
- package/dist/components-harmony-ets/movableArea.ets +96 -0
- package/dist/components-harmony-ets/movableView.ets +74 -0
- package/dist/components-harmony-ets/picker.ets +32 -147
- package/dist/components-harmony-ets/progress.ets +54 -0
- package/dist/components-harmony-ets/pseudo.ets +80 -0
- package/dist/components-harmony-ets/radio.ets +23 -210
- package/dist/components-harmony-ets/richText.ets +22 -102
- package/dist/components-harmony-ets/scrollView.ets +73 -169
- package/dist/components-harmony-ets/slider.ets +11 -72
- package/dist/components-harmony-ets/style.ets +280 -0
- package/dist/components-harmony-ets/swiper.ets +37 -87
- package/dist/components-harmony-ets/switch.ets +11 -71
- package/dist/components-harmony-ets/text.ets +57 -89
- package/dist/components-harmony-ets/textArea.ets +11 -67
- package/dist/components-harmony-ets/utils/AttributeManager.ets +1 -1
- package/dist/components-harmony-ets/utils/DynamicCenter.ts +1 -1
- package/dist/components-harmony-ets/utils/flexManager.ets +11 -9
- package/dist/components-harmony-ets/utils/helper.ets +4 -5
- package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
- package/dist/components-harmony-ets/utils/htmlParser/index.ts +1 -1
- package/dist/components-harmony-ets/utils/index.ts +50 -51
- package/dist/components-harmony-ets/utils/styles.ets +167 -87
- package/dist/components-harmony-ets/video.ets +41 -89
- package/dist/components-harmony-ets/view.ets +53 -159
- package/dist/components-harmony-ets/webView.ets +44 -99
- package/dist/index.d.ts +151 -0
- package/dist/index.js +69 -32
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/bom/window.ts +7 -0
- package/dist/runtime-ets/current.ts +3 -0
- package/dist/runtime-ets/dom/bind.ts +20 -6
- package/dist/runtime-ets/dom/cssNesting.ts +393 -0
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +12 -40
- package/dist/runtime-ets/dom/document.ts +22 -8
- package/dist/runtime-ets/dom/element/canvas.ts +136 -0
- package/dist/runtime-ets/dom/element/element.ts +128 -51
- package/dist/runtime-ets/dom/element/form.ts +15 -18
- package/dist/runtime-ets/dom/element/index.ts +16 -3
- package/dist/runtime-ets/dom/element/movableArea.ts +12 -0
- package/dist/runtime-ets/dom/element/movableView.ts +193 -0
- package/dist/runtime-ets/dom/element/normal.ts +8 -3
- package/dist/runtime-ets/dom/element/progress.ts +12 -0
- package/dist/runtime-ets/dom/element/scrollView.ts +1 -0
- package/dist/runtime-ets/dom/element/text.ts +1 -8
- package/dist/runtime-ets/dom/element/video.ts +5 -3
- package/dist/runtime-ets/dom/element/webView.ts +8 -0
- package/dist/runtime-ets/dom/event.ts +0 -1
- package/dist/runtime-ets/dom/eventTarget.ts +0 -3
- package/dist/runtime-ets/dom/node.ts +29 -27
- package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +189 -211
- package/dist/runtime-ets/dom/stylesheet/index.ts +28 -308
- package/dist/runtime-ets/dom/stylesheet/type.ts +18 -6
- package/dist/runtime-ets/dom/stylesheet/util.ts +31 -25
- package/dist/runtime-ets/index.ts +2 -2
- package/dist/runtime-ets/interface/event.ts +1 -1
- package/dist/runtime-ets/utils/index.ts +43 -10
- package/dist/runtime-ets/utils/info.ts +1 -1
- package/dist/runtime-framework/react/app.ts +7 -2
- package/dist/runtime-framework/react/index.ts +0 -2
- package/dist/runtime-framework/react/native-page.ts +22 -12
- package/dist/runtime-framework/react/page.ts +3 -8
- package/dist/runtime-framework/solid/app.ts +25 -45
- package/dist/runtime-framework/solid/connect.ts +21 -3
- package/dist/runtime-framework/solid/hooks.ts +16 -11
- package/dist/runtime-framework/solid/index.ts +6 -2
- package/dist/runtime-framework/solid/page.ts +84 -30
- package/dist/runtime-framework/solid/reconciler/props.ts +65 -20
- package/dist/runtime-framework/solid/reconciler/render.ts +16 -6
- package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
- package/dist/runtime-framework/solid/utils/index.ts +0 -2
- package/dist/runtime-utils.d.ts +827 -0
- package/dist/runtime-utils.js +273 -109
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.js +273 -109
- package/dist/runtime.js.map +1 -1
- package/index.js +3 -1
- package/package.json +13 -13
- package/types/index.d.ts +4 -0
- package/dist/runtime-ets/utils/bind.ts +0 -24
- /package/dist/components-harmony-ets/{index.ts → tag.ts} +0 -0
- /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { TaroElement } from './element'
|
|
2
|
+
|
|
3
|
+
import type { MovableViewProps } from '@tarojs/components/types'
|
|
4
|
+
|
|
5
|
+
type Tsize = {
|
|
6
|
+
w: number
|
|
7
|
+
h: number
|
|
8
|
+
}
|
|
9
|
+
type Tpoint = {
|
|
10
|
+
x: number
|
|
11
|
+
y: number
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function calcPosition(postion: number, start: number, end: number) {
|
|
15
|
+
if (postion <= end && postion >= start) {
|
|
16
|
+
return postion
|
|
17
|
+
} else if (postion < start) {
|
|
18
|
+
return start
|
|
19
|
+
} else {
|
|
20
|
+
return end
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@Observed
|
|
25
|
+
export class TaroMovableViewElement extends TaroElement<MovableViewProps & { animation: undefined }> {
|
|
26
|
+
_scaleValue = 1
|
|
27
|
+
_scalevalueTemp = 1
|
|
28
|
+
|
|
29
|
+
// 父级区别的大小
|
|
30
|
+
_area?: Tsize
|
|
31
|
+
// 自己元素的大小
|
|
32
|
+
_selfSize?: Tsize
|
|
33
|
+
|
|
34
|
+
// 元素的位置
|
|
35
|
+
_position: Tpoint = {
|
|
36
|
+
x: 0,
|
|
37
|
+
y: 0,
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
_positionTemp: Tpoint = {
|
|
41
|
+
x: 0,
|
|
42
|
+
y: 0,
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
constructor() {
|
|
46
|
+
super('MovableView')
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
get _outOfBounds() {
|
|
50
|
+
if (this.getAttribute('outOfBounds')) {
|
|
51
|
+
return this.selfSize ? this.selfSize.w / 3 : 0
|
|
52
|
+
}
|
|
53
|
+
return 0
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
set area(val: Tsize) {
|
|
57
|
+
this._area = val
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
get area(): Tsize | undefined {
|
|
61
|
+
return this._area
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
startScale() {
|
|
65
|
+
this._scalevalueTemp = this._scaleValue
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
doScale(val: number) {
|
|
69
|
+
const scale = this.getAttribute('scale')
|
|
70
|
+
|
|
71
|
+
// 禁止缩放的时候不生效
|
|
72
|
+
if (scale) {
|
|
73
|
+
this.scaleValue = val * this._scalevalueTemp
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
set scaleValue(val: number) {
|
|
78
|
+
if (this.checkScaleValueInBounds(val)) {
|
|
79
|
+
this._scaleValue = val
|
|
80
|
+
|
|
81
|
+
this.checkPositionBoundary(this.position, val)
|
|
82
|
+
|
|
83
|
+
const bindscale = this.getAttribute('bindscale')
|
|
84
|
+
typeof bindscale === 'function' && bindscale({ ...this.position, scale: this.scaleValue })
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
get scaleValue() {
|
|
89
|
+
return this._scaleValue
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
startMove() {
|
|
93
|
+
this._positionTemp = this._position
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
doMove(val: Tpoint) {
|
|
97
|
+
if (!this.area || !this.selfSize) return
|
|
98
|
+
if (this.getAttribute('disabled')) return
|
|
99
|
+
const direction = this.getAttribute('direction')
|
|
100
|
+
|
|
101
|
+
// 容器的宽高终点
|
|
102
|
+
const areaWidthEnd = this.area.w - this.selfSize.w * this.scaleValue
|
|
103
|
+
const areaHeightEnd = this.area.h - this.selfSize.h * this.scaleValue
|
|
104
|
+
|
|
105
|
+
const incrementWidth = (this.scaleValue - 1) * this.selfSize.w
|
|
106
|
+
const incrementHeight = (this.scaleValue - 1) * this.selfSize.h
|
|
107
|
+
|
|
108
|
+
let x = this._positionTemp.x
|
|
109
|
+
let y = this._positionTemp.y
|
|
110
|
+
if (['all', 'horizontal'].includes(direction)) {
|
|
111
|
+
const nextX = this._positionTemp.x + val.x * this.scaleValue
|
|
112
|
+
x = calcPosition(
|
|
113
|
+
nextX,
|
|
114
|
+
incrementWidth * 0.5 - this._outOfBounds,
|
|
115
|
+
areaWidthEnd + incrementWidth * 0.5 + this._outOfBounds
|
|
116
|
+
)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (['all', 'vertical'].includes(direction)) {
|
|
120
|
+
const nextY = this._positionTemp.y + val.y * this.scaleValue
|
|
121
|
+
y = calcPosition(
|
|
122
|
+
nextY,
|
|
123
|
+
incrementHeight * 0.5 - this._outOfBounds,
|
|
124
|
+
areaHeightEnd + incrementHeight * 0.5 + this._outOfBounds
|
|
125
|
+
)
|
|
126
|
+
}
|
|
127
|
+
const bindchange = this.getAttribute('bindchange')
|
|
128
|
+
if (typeof bindchange === 'function') {
|
|
129
|
+
bindchange({ x, y, source: 'touch' })
|
|
130
|
+
}
|
|
131
|
+
this.position = {
|
|
132
|
+
x: x,
|
|
133
|
+
y: y,
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
get position() {
|
|
138
|
+
return this._position
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
set position(val: Tpoint) {
|
|
142
|
+
this._position = val
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
set selfSize(val: Tsize) {
|
|
146
|
+
this._selfSize = val
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
get selfSize(): Tsize | undefined {
|
|
150
|
+
return this._selfSize
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
checkPositionBoundary(position: Tpoint, scale: number) {
|
|
154
|
+
if (!this.area || !this.selfSize) {
|
|
155
|
+
return { x: 0, y: 0 }
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const areaWidthEnd = this.area.w - this.selfSize.w * scale
|
|
159
|
+
const areaHeightEnd = this.area.h - this.selfSize.h * scale
|
|
160
|
+
|
|
161
|
+
const incrementWidth = (scale - 1) * this.selfSize.w
|
|
162
|
+
const incrementHeight = (scale - 1) * this.selfSize.h
|
|
163
|
+
|
|
164
|
+
this.position = {
|
|
165
|
+
x: calcPosition(position.x, incrementWidth * 0.5, areaWidthEnd + incrementWidth * 0.5),
|
|
166
|
+
y: calcPosition(position.y, incrementHeight * 0.5, areaHeightEnd + incrementHeight * 0.5),
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
checkScaleValueInBounds(currentScale: number) {
|
|
171
|
+
const scaleMin = this.getAttribute('scaleMin')
|
|
172
|
+
const scaleMax = this.getAttribute('scaleMax')
|
|
173
|
+
|
|
174
|
+
if (scaleMin && Number(scaleMin) >= 0.1 && currentScale < Number(scaleMin)) {
|
|
175
|
+
return false
|
|
176
|
+
} else if (scaleMax && Number(scaleMax) >= 0.1 && currentScale > Number(scaleMax)) {
|
|
177
|
+
return false
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return true
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
public setAttribute(name: string, value: any): void {
|
|
184
|
+
if (name === 'x') {
|
|
185
|
+
this.checkPositionBoundary({ x: value, y: this.position.y }, this.scaleValue)
|
|
186
|
+
}
|
|
187
|
+
if (name === 'y') {
|
|
188
|
+
this.checkPositionBoundary({ x: this.position.x, y: value }, this.scaleValue)
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
super.setAttribute(name, value)
|
|
192
|
+
}
|
|
193
|
+
}
|
|
@@ -12,43 +12,48 @@ import type {
|
|
|
12
12
|
ViewProps
|
|
13
13
|
} from '@tarojs/components/types'
|
|
14
14
|
|
|
15
|
+
@Observed
|
|
15
16
|
class TaroViewElement extends TaroElement<ViewProps> {
|
|
16
17
|
constructor() {
|
|
17
18
|
super('View')
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
|
|
22
|
+
@Observed
|
|
21
23
|
class TaroImageElement extends TaroElement<ImageProps> {
|
|
22
24
|
constructor() {
|
|
23
25
|
super('Image')
|
|
24
26
|
}
|
|
25
27
|
}
|
|
26
28
|
|
|
29
|
+
@Observed
|
|
27
30
|
class TaroButtonElement extends TaroElement<ButtonProps> {
|
|
28
31
|
constructor() {
|
|
29
32
|
super('Button')
|
|
30
33
|
}
|
|
31
34
|
}
|
|
32
35
|
|
|
33
|
-
|
|
36
|
+
@Observed
|
|
34
37
|
class TaroIconElement extends TaroElement<IconProps>{
|
|
35
38
|
constructor() {
|
|
36
39
|
super('Icon')
|
|
37
40
|
}
|
|
38
41
|
}
|
|
39
|
-
|
|
42
|
+
@Observed
|
|
40
43
|
class TaroLabelElement extends TaroElement<LabelProps>{
|
|
41
44
|
constructor() {
|
|
42
45
|
super('Label')
|
|
43
46
|
}
|
|
44
47
|
}
|
|
45
48
|
|
|
49
|
+
@Observed
|
|
46
50
|
class TaroRichTextElement extends TaroElement<RichTextProps>{
|
|
47
51
|
constructor() {
|
|
48
52
|
super('RichText')
|
|
49
53
|
}
|
|
50
54
|
}
|
|
51
55
|
|
|
56
|
+
@Observed
|
|
52
57
|
class TaroSwiperElement extends TaroElement<SwiperProps>{
|
|
53
58
|
controller: SwiperController = new SwiperController()
|
|
54
59
|
|
|
@@ -57,13 +62,13 @@ class TaroSwiperElement extends TaroElement<SwiperProps>{
|
|
|
57
62
|
}
|
|
58
63
|
}
|
|
59
64
|
|
|
65
|
+
@Observed
|
|
60
66
|
class TaroSwiperItemElement extends TaroElement<SwiperItemProps>{
|
|
61
67
|
constructor() {
|
|
62
68
|
super('SwiperItem')
|
|
63
69
|
}
|
|
64
70
|
}
|
|
65
71
|
|
|
66
|
-
|
|
67
72
|
export {
|
|
68
73
|
TaroButtonElement,
|
|
69
74
|
TaroIconElement,
|
|
@@ -1,17 +1,10 @@
|
|
|
1
|
-
import { TaroNode } from '../node'
|
|
2
1
|
import { TaroElement } from './element'
|
|
3
2
|
|
|
4
3
|
import type { TextProps } from '@tarojs/components/types'
|
|
5
4
|
|
|
5
|
+
@Observed
|
|
6
6
|
export class TaroTextElement extends TaroElement<TextProps> {
|
|
7
7
|
constructor() {
|
|
8
8
|
super('Text')
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
public appendChild (child: TaroNode): TaroNode {
|
|
12
|
-
super.appendChild(child)
|
|
13
|
-
|
|
14
|
-
this.updateComponent()
|
|
15
|
-
return child
|
|
16
|
-
}
|
|
17
10
|
}
|
|
@@ -2,13 +2,15 @@ import { TaroElement } from './element'
|
|
|
2
2
|
|
|
3
3
|
import type { VideoProps } from '@tarojs/components/types'
|
|
4
4
|
|
|
5
|
+
@Observed
|
|
5
6
|
export class TaroVideoElement extends TaroElement<VideoProps> {
|
|
6
|
-
_currentTime = 0
|
|
7
7
|
|
|
8
8
|
controller: VideoController = new VideoController()
|
|
9
9
|
|
|
10
10
|
constructor() {
|
|
11
11
|
super('Video')
|
|
12
|
+
|
|
13
|
+
this._nodeInfo._currentTime = 0
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
async play() {
|
|
@@ -39,11 +41,11 @@ export class TaroVideoElement extends TaroElement<VideoProps> {
|
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
get currentTime() {
|
|
42
|
-
return this._currentTime
|
|
44
|
+
return this._nodeInfo._currentTime
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
set currentTime(val: number) {
|
|
46
|
-
this._currentTime = val
|
|
48
|
+
this._nodeInfo._currentTime = val
|
|
47
49
|
this.controller.setCurrentTime(val)
|
|
48
50
|
}
|
|
49
51
|
}
|
|
@@ -5,6 +5,14 @@ import { TaroElement } from './element'
|
|
|
5
5
|
|
|
6
6
|
import type { WebViewProps } from '@tarojs/components/types'
|
|
7
7
|
|
|
8
|
+
@Observed
|
|
9
|
+
export class TaroInnerHtmlElement extends TaroElement {
|
|
10
|
+
constructor() {
|
|
11
|
+
super('InnerHtml')
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@Observed
|
|
8
16
|
export class TaroWebViewElement extends TaroElement<WebViewProps>{
|
|
9
17
|
ports: web_webview.WebMessagePort[] = []
|
|
10
18
|
|
|
@@ -68,12 +68,10 @@ class TaroEventTarget extends Events {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
|
|
72
71
|
if (event._stop) {
|
|
73
72
|
this._stopPropagation(event)
|
|
74
73
|
}
|
|
75
74
|
|
|
76
|
-
|
|
77
75
|
return listeners != null
|
|
78
76
|
}
|
|
79
77
|
|
|
@@ -95,5 +93,4 @@ class TaroEventTarget extends Events {
|
|
|
95
93
|
}
|
|
96
94
|
}
|
|
97
95
|
|
|
98
|
-
|
|
99
96
|
export { TaroEventTarget }
|
|
@@ -59,31 +59,29 @@ export class TaroNode extends TaroDataSourceElement {
|
|
|
59
59
|
return this.childNodes[index] as TaroElement
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
public findIndex (refChild
|
|
63
|
-
return this.childNodes.findIndex(node => node._nid === refChild
|
|
62
|
+
public findIndex (refChild?: TaroNode): number {
|
|
63
|
+
return this.childNodes.findIndex(node => node._nid === refChild?._nid)
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if (
|
|
66
|
+
public updateTextNode () {
|
|
67
|
+
// @ts-ignore
|
|
68
|
+
if (this.childNodes.length <= 0 || this.tagName !== 'VIEW') return
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
// TextNode 不具备 props 更新能力,需要由父节点来进行触发
|
|
71
|
+
this.childNodes.forEach(item => {
|
|
72
|
+
if (item.nodeType !== NodeType.TEXT_NODE) return
|
|
73
|
+
|
|
74
|
+
item._updateTrigger++
|
|
75
|
+
})
|
|
76
|
+
}
|
|
71
77
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
this.parentNode.updateComponent()
|
|
78
|
-
}
|
|
78
|
+
// 更新对应的 ArkUI 组件
|
|
79
|
+
public updateComponent () {
|
|
80
|
+
// 非半编译模式或者半编译模式下拥有自主更新权力的节点走 @State 的更新模式
|
|
81
|
+
if (this._isDynamicNode || !this._isCompileMode) {
|
|
82
|
+
this._updateTrigger++
|
|
79
83
|
} else {
|
|
80
|
-
|
|
81
|
-
if (idx >= 0) {
|
|
82
|
-
this._updateTrigger++
|
|
83
|
-
this.parentNode.notifyDataChange(idx)
|
|
84
|
-
} else {
|
|
85
|
-
this.parentNode.notifyDataReload()
|
|
86
|
-
}
|
|
84
|
+
this.parentNode?.updateComponent()
|
|
87
85
|
}
|
|
88
86
|
}
|
|
89
87
|
|
|
@@ -128,11 +126,12 @@ export class TaroNode extends TaroDataSourceElement {
|
|
|
128
126
|
public set textContent (value: string) {
|
|
129
127
|
if (this.nodeType === NodeType.TEXT_NODE) {
|
|
130
128
|
this._textContent = value
|
|
131
|
-
this.parentNode?.updateComponent()
|
|
132
129
|
} else if (this.nodeType === NodeType.ELEMENT_NODE) {
|
|
133
130
|
const node = new TaroTextNode(value)
|
|
134
131
|
node._doc = this.ownerDocument
|
|
135
|
-
|
|
132
|
+
node.parentNode = this
|
|
133
|
+
this.childNodes.length = 0
|
|
134
|
+
this.childNodes.push(node)
|
|
136
135
|
}
|
|
137
136
|
}
|
|
138
137
|
|
|
@@ -150,7 +149,6 @@ export class TaroNode extends TaroDataSourceElement {
|
|
|
150
149
|
public set nodeValue (value: string | null) {
|
|
151
150
|
if (this.nodeType === NodeType.TEXT_NODE && value) {
|
|
152
151
|
this.textContent = value
|
|
153
|
-
this.parentNode?.updateComponent()
|
|
154
152
|
}
|
|
155
153
|
}
|
|
156
154
|
|
|
@@ -163,11 +161,13 @@ export class TaroNode extends TaroDataSourceElement {
|
|
|
163
161
|
}
|
|
164
162
|
|
|
165
163
|
// TODO cloneNode()、contains()
|
|
166
|
-
|
|
167
|
-
public appendChild (child: TaroNode): TaroNode {
|
|
164
|
+
public connectParentNode (child: TaroNode) {
|
|
168
165
|
child.parentNode?.removeChild(child)
|
|
169
166
|
child.parentNode = this
|
|
167
|
+
}
|
|
170
168
|
|
|
169
|
+
public appendChild (child: TaroNode): TaroNode {
|
|
170
|
+
this.connectParentNode(child)
|
|
171
171
|
this.childNodes.push(child)
|
|
172
172
|
this.notifyDataAdd(this.childNodes.length - 1)
|
|
173
173
|
|
|
@@ -175,14 +175,15 @@ export class TaroNode extends TaroDataSourceElement {
|
|
|
175
175
|
return child
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
public insertBefore (newNode: TaroNode, referenceNode
|
|
178
|
+
public insertBefore (newNode: TaroNode, referenceNode?: TaroNode): TaroNode {
|
|
179
179
|
newNode.parentNode?.removeChild(newNode)
|
|
180
180
|
|
|
181
|
-
if (referenceNode
|
|
181
|
+
if (!referenceNode) {
|
|
182
182
|
this.appendChild(newNode)
|
|
183
183
|
} else {
|
|
184
184
|
const idxOfRef = this.findIndex(referenceNode)
|
|
185
185
|
this.childNodes.splice(idxOfRef, 0, newNode)
|
|
186
|
+
this.connectParentNode(newNode)
|
|
186
187
|
// TODO: 优化
|
|
187
188
|
this.notifyDataReload()
|
|
188
189
|
}
|
|
@@ -229,6 +230,7 @@ export class TaroNode extends TaroDataSourceElement {
|
|
|
229
230
|
}
|
|
230
231
|
}
|
|
231
232
|
|
|
233
|
+
@Observed
|
|
232
234
|
export class TaroTextNode extends TaroNode {
|
|
233
235
|
constructor(value = '', nodeName = '#text', nodeType: NodeType = NodeType.TEXT_NODE) {
|
|
234
236
|
super(nodeName, nodeType)
|