@dooboostore/dom-render 1.0.110 → 1.0.112
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/README.MD +1 -2
- package/dist/cjs/DomRenderProxy.js +89 -48
- package/dist/cjs/DomRenderProxy.js.map +2 -2
- package/dist/cjs/components/ComponentBase.js +47 -1
- package/dist/cjs/components/ComponentBase.js.map +2 -2
- package/dist/cjs/components/a/A.js +22 -0
- package/dist/cjs/components/a/A.js.map +2 -2
- package/dist/cjs/components/appender/Appender.js +21 -4
- package/dist/cjs/components/appender/Appender.js.map +2 -2
- package/dist/cjs/components/details/Details.js +5 -0
- package/dist/cjs/components/details/Details.js.map +2 -2
- package/dist/cjs/components/forOf/ForOf.js +2 -2
- package/dist/cjs/components/forOf/ForOf.js.map +1 -1
- package/dist/cjs/components/if/If.js +1 -1
- package/dist/cjs/components/if/If.js.map +2 -2
- package/dist/cjs/components/index.js +3 -1
- package/dist/cjs/components/index.js.map +3 -3
- package/dist/cjs/components/router/RouterOutlet.js +41 -10
- package/dist/cjs/components/router/RouterOutlet.js.map +2 -2
- package/dist/cjs/components/select/Select.js +39 -1
- package/dist/cjs/components/select/Select.js.map +2 -2
- package/dist/cjs/components/this/This.js +33 -5
- package/dist/cjs/components/this/This.js.map +2 -2
- package/dist/cjs/decorators/DomRenderNoProxy.js +3 -9
- package/dist/cjs/decorators/DomRenderNoProxy.js.map +2 -2
- package/dist/cjs/events/EventManager.js +103 -37
- package/dist/cjs/events/EventManager.js.map +2 -2
- package/dist/cjs/lifecycle/OnChangeAttrRender.js.map +1 -1
- package/dist/cjs/lifecycle/OnChildRawSetRendered.js +26 -0
- package/dist/cjs/lifecycle/OnChildRawSetRendered.js.map +7 -0
- package/dist/cjs/lifecycle/OnRawSetRendered.js.map +2 -2
- package/dist/cjs/operators/Appender.js +8 -1
- package/dist/cjs/operators/Appender.js.map +2 -2
- package/dist/cjs/operators/Dr.js +2 -2
- package/dist/cjs/operators/Dr.js.map +2 -2
- package/dist/cjs/operators/DrAppender.js +2 -2
- package/dist/cjs/operators/DrAppender.js.map +2 -2
- package/dist/cjs/operators/DrFor.js +2 -2
- package/dist/cjs/operators/DrFor.js.map +2 -2
- package/dist/cjs/operators/DrForOf.js +34 -6
- package/dist/cjs/operators/DrForOf.js.map +2 -2
- package/dist/cjs/operators/DrForm.js +6 -6
- package/dist/cjs/operators/DrForm.js.map +2 -2
- package/dist/cjs/operators/DrInnerHTML.js +2 -2
- package/dist/cjs/operators/DrInnerHTML.js.map +2 -2
- package/dist/cjs/operators/DrRepeat.js +2 -2
- package/dist/cjs/operators/DrRepeat.js.map +2 -2
- package/dist/cjs/operators/DrStripElement.js +2 -2
- package/dist/cjs/operators/DrStripElement.js.map +2 -2
- package/dist/cjs/operators/DrTargetElement.js +14 -5
- package/dist/cjs/operators/DrTargetElement.js.map +2 -2
- package/dist/cjs/operators/DrTargetElementIsElement.js +2 -2
- package/dist/cjs/operators/DrTargetElementIsElement.js.map +2 -2
- package/dist/cjs/operators/DrThis.js +2 -2
- package/dist/cjs/operators/DrThis.js.map +2 -2
- package/dist/cjs/operators/DrThisProperty.js +2 -1
- package/dist/cjs/operators/DrThisProperty.js.map +2 -2
- package/dist/cjs/rawsets/RawSet.js +87 -160
- package/dist/cjs/rawsets/RawSet.js.map +2 -2
- package/dist/cjs/routers/HashRouter.js +3 -0
- package/dist/cjs/routers/HashRouter.js.map +2 -2
- package/dist/cjs/routers/PathRouter.js +3 -0
- package/dist/cjs/routers/PathRouter.js.map +2 -2
- package/dist/cjs/routers/Router.js +25 -21
- package/dist/cjs/routers/Router.js.map +2 -2
- package/dist/esm/DomRenderProxy.js +89 -48
- package/dist/esm/DomRenderProxy.js.map +2 -2
- package/dist/esm/components/ComponentBase.js +47 -1
- package/dist/esm/components/ComponentBase.js.map +2 -2
- package/dist/esm/components/a/A.js +22 -0
- package/dist/esm/components/a/A.js.map +2 -2
- package/dist/esm/components/appender/Appender.js +22 -5
- package/dist/esm/components/appender/Appender.js.map +2 -2
- package/dist/esm/components/details/Details.js +5 -0
- package/dist/esm/components/details/Details.js.map +2 -2
- package/dist/esm/components/forOf/ForOf.js +2 -2
- package/dist/esm/components/forOf/ForOf.js.map +1 -1
- package/dist/esm/components/if/If.js +1 -1
- package/dist/esm/components/if/If.js.map +2 -2
- package/dist/esm/components/index.js +3 -1
- package/dist/esm/components/index.js.map +2 -2
- package/dist/esm/components/router/RouterOutlet.js +41 -10
- package/dist/esm/components/router/RouterOutlet.js.map +2 -2
- package/dist/esm/components/select/Select.js +39 -1
- package/dist/esm/components/select/Select.js.map +2 -2
- package/dist/esm/components/this/This.js +33 -5
- package/dist/esm/components/this/This.js.map +2 -2
- package/dist/esm/decorators/DomRenderNoProxy.js +3 -9
- package/dist/esm/decorators/DomRenderNoProxy.js.map +2 -2
- package/dist/esm/events/EventManager.js +103 -37
- package/dist/esm/events/EventManager.js.map +2 -2
- package/dist/esm/lifecycle/OnChangeAttrRender.js.map +1 -1
- package/dist/esm/lifecycle/OnChildRawSetRendered.js +7 -0
- package/dist/esm/lifecycle/OnChildRawSetRendered.js.map +7 -0
- package/dist/esm/lifecycle/OnRawSetRendered.js.map +2 -2
- package/dist/esm/operators/Appender.js +8 -1
- package/dist/esm/operators/Appender.js.map +2 -2
- package/dist/esm/operators/Dr.js +2 -2
- package/dist/esm/operators/Dr.js.map +2 -2
- package/dist/esm/operators/DrAppender.js +2 -2
- package/dist/esm/operators/DrAppender.js.map +2 -2
- package/dist/esm/operators/DrFor.js +2 -2
- package/dist/esm/operators/DrFor.js.map +2 -2
- package/dist/esm/operators/DrForOf.js +34 -6
- package/dist/esm/operators/DrForOf.js.map +2 -2
- package/dist/esm/operators/DrForm.js +6 -6
- package/dist/esm/operators/DrForm.js.map +2 -2
- package/dist/esm/operators/DrInnerHTML.js +2 -2
- package/dist/esm/operators/DrInnerHTML.js.map +2 -2
- package/dist/esm/operators/DrRepeat.js +2 -2
- package/dist/esm/operators/DrRepeat.js.map +2 -2
- package/dist/esm/operators/DrStripElement.js +2 -2
- package/dist/esm/operators/DrStripElement.js.map +2 -2
- package/dist/esm/operators/DrTargetElement.js +14 -5
- package/dist/esm/operators/DrTargetElement.js.map +2 -2
- package/dist/esm/operators/DrTargetElementIsElement.js +2 -2
- package/dist/esm/operators/DrTargetElementIsElement.js.map +2 -2
- package/dist/esm/operators/DrThis.js +2 -2
- package/dist/esm/operators/DrThis.js.map +2 -2
- package/dist/esm/operators/DrThisProperty.js +2 -1
- package/dist/esm/operators/DrThisProperty.js.map +2 -2
- package/dist/esm/rawsets/RawSet.js +87 -160
- package/dist/esm/rawsets/RawSet.js.map +2 -2
- package/dist/esm/routers/HashRouter.js +3 -0
- package/dist/esm/routers/HashRouter.js.map +2 -2
- package/dist/esm/routers/PathRouter.js +3 -0
- package/dist/esm/routers/PathRouter.js.map +2 -2
- package/dist/esm/routers/Router.js +25 -21
- package/dist/esm/routers/Router.js.map +2 -2
- package/dist/esm-bundle/dooboostore-dom-render.esm.js +830 -1533
- package/dist/esm-bundle/dooboostore-dom-render.esm.js.map +4 -4
- package/dist/types/DomRenderProxy.d.ts.map +1 -1
- package/dist/types/components/ComponentBase.d.ts +12 -1
- package/dist/types/components/ComponentBase.d.ts.map +1 -1
- package/dist/types/components/a/A.d.ts +6 -0
- package/dist/types/components/a/A.d.ts.map +1 -1
- package/dist/types/components/appender/Appender.d.ts +1 -0
- package/dist/types/components/appender/Appender.d.ts.map +1 -1
- package/dist/types/components/details/Details.d.ts +2 -0
- package/dist/types/components/details/Details.d.ts.map +1 -1
- package/dist/types/components/forOf/ForOf.d.ts +1 -1
- package/dist/types/components/forOf/ForOf.d.ts.map +1 -1
- package/dist/types/components/if/If.d.ts.map +1 -1
- package/dist/types/components/index.d.ts +1 -0
- package/dist/types/components/index.d.ts.map +1 -1
- package/dist/types/components/router/RouterOutlet.d.ts +6 -3
- package/dist/types/components/router/RouterOutlet.d.ts.map +1 -1
- package/dist/types/components/select/Select.d.ts +5 -3
- package/dist/types/components/select/Select.d.ts.map +1 -1
- package/dist/types/components/this/This.d.ts +5 -1
- package/dist/types/components/this/This.d.ts.map +1 -1
- package/dist/types/decorators/DomRenderNoProxy.d.ts.map +1 -1
- package/dist/types/events/EventManager.d.ts +1 -0
- package/dist/types/events/EventManager.d.ts.map +1 -1
- package/dist/types/lifecycle/OnChangeAttrRender.d.ts +1 -1
- package/dist/types/lifecycle/OnChangeAttrRender.d.ts.map +1 -1
- package/dist/types/lifecycle/OnChildRawSetRendered.d.ts +9 -0
- package/dist/types/lifecycle/OnChildRawSetRendered.d.ts.map +1 -0
- package/dist/types/lifecycle/OnRawSetRendered.d.ts +2 -0
- package/dist/types/lifecycle/OnRawSetRendered.d.ts.map +1 -1
- package/dist/types/operators/Appender.d.ts +1 -0
- package/dist/types/operators/Appender.d.ts.map +1 -1
- package/dist/types/operators/Dr.d.ts.map +1 -1
- package/dist/types/operators/DrAppender.d.ts.map +1 -1
- package/dist/types/operators/DrFor.d.ts.map +1 -1
- package/dist/types/operators/DrForOf.d.ts.map +1 -1
- package/dist/types/operators/DrForm.d.ts.map +1 -1
- package/dist/types/operators/DrInnerHTML.d.ts.map +1 -1
- package/dist/types/operators/DrRepeat.d.ts.map +1 -1
- package/dist/types/operators/DrStripElement.d.ts.map +1 -1
- package/dist/types/operators/DrTargetElement.d.ts.map +1 -1
- package/dist/types/operators/DrThisProperty.d.ts.map +1 -1
- package/dist/types/rawsets/RawSet.d.ts +4 -1
- package/dist/types/rawsets/RawSet.d.ts.map +1 -1
- package/dist/types/routers/HashRouter.d.ts +1 -0
- package/dist/types/routers/HashRouter.d.ts.map +1 -1
- package/dist/types/routers/PathRouter.d.ts +1 -0
- package/dist/types/routers/PathRouter.d.ts.map +1 -1
- package/dist/types/routers/Router.d.ts +3 -0
- package/dist/types/routers/Router.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-dom-render.umd.js +830 -1533
- package/dist/umd-bundle/dooboostore-dom-render.umd.js.map +4 -4
- package/package.json +4 -4
- package/src/DomRenderProxy.ts +169 -75
- package/src/DomRenderProxy.ts_cache_back +1031 -0
- package/src/components/ComponentBase.ts +61 -5
- package/src/components/a/A.ts +25 -0
- package/src/components/appender/Appender.ts +3 -3
- package/src/components/details/Details.ts +7 -0
- package/src/components/forOf/ForOf.ts +2 -2
- package/src/components/if/If.ts +3 -2
- package/src/components/index.ts +3 -0
- package/src/components/router/RouterOutlet.ts +60 -22
- package/src/components/select/Select.ts +69 -30
- package/src/components/this/This.ts +41 -6
- package/src/decorators/DomRenderNoProxy.ts +17 -14
- package/src/events/EventManager.ts +180 -77
- package/src/lifecycle/OnChangeAttrRender.ts +1 -1
- package/src/lifecycle/OnChildRawSetRendered.ts +13 -0
- package/src/lifecycle/OnRawSetRendered.ts +3 -1
- package/src/operators/Appender.ts +8 -1
- package/src/operators/Dr.ts +2 -1
- package/src/operators/DrAppender.ts +2 -1
- package/src/operators/DrFor.ts +2 -1
- package/src/operators/DrForOf.ts +36 -6
- package/src/operators/DrForm.ts +6 -5
- package/src/operators/DrInnerHTML.ts +2 -1
- package/src/operators/DrRepeat.ts +2 -1
- package/src/operators/DrStripElement.ts +2 -1
- package/src/operators/DrTargetElement.ts +17 -5
- package/src/operators/DrTargetElementIsElement.ts +2 -2
- package/src/operators/DrThis.ts +2 -2
- package/src/operators/DrThisProperty.ts +2 -1
- package/src/rawsets/RawSet.ts +161 -237
- package/src/routers/HashRouter.ts +4 -0
- package/src/routers/PathRouter.ts +5 -0
- package/src/routers/Router.ts +64 -47
- package/src/node_modules/.bin/acorn +0 -17
- package/src/node_modules/.bin/browserslist +0 -17
- package/src/node_modules/.bin/eslint +0 -17
- package/src/node_modules/.bin/sbf +0 -17
- package/src/node_modules/.bin/ts-node +0 -17
- package/src/node_modules/.bin/ts-node-cwd +0 -17
- package/src/node_modules/.bin/ts-node-dev +0 -17
- package/src/node_modules/.bin/ts-node-esm +0 -17
- package/src/node_modules/.bin/ts-node-script +0 -17
- package/src/node_modules/.bin/ts-node-transpile-only +0 -17
- package/src/node_modules/.bin/ts-script +0 -17
- package/src/node_modules/.bin/tsc +0 -17
- package/src/node_modules/.bin/tsnd +0 -17
- package/src/node_modules/.bin/tsserver +0 -17
- package/src/node_modules/.bin/webpack +0 -17
- package/src/node_modules/.bin/webpack-cli +0 -17
- package/src/node_modules/.bin/webpack-dev-server +0 -17
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ComponentBase } from '../ComponentBase';
|
|
2
2
|
import { DomRender, DomRenderRunConfig } from '../../DomRender';
|
|
3
3
|
import { RawSet } from '../../rawsets/RawSet';
|
|
4
|
-
import { OtherData } from '../../lifecycle/OnChangeAttrRender';
|
|
4
|
+
import { isOnChangeAttrRender, OtherData } from '../../lifecycle/OnChangeAttrRender';
|
|
5
5
|
import { OnInitRender } from '../../lifecycle/OnInitRender';
|
|
6
6
|
import { ComponentSet } from '../../components/ComponentSet';
|
|
7
7
|
import { OnDestroyRenderParams } from '../../lifecycle/OnDestroyRender';
|
|
@@ -20,6 +20,20 @@ export namespace This {
|
|
|
20
20
|
private value?: ComponentSet;
|
|
21
21
|
private if?: boolean | null = null;
|
|
22
22
|
private createArguments?: any[];
|
|
23
|
+
private childObject?: any;
|
|
24
|
+
private childRawSet?: RawSet;
|
|
25
|
+
private sw = false;
|
|
26
|
+
|
|
27
|
+
setValue(value: ComponentSet) {
|
|
28
|
+
this.sw = false;
|
|
29
|
+
setTimeout(() => {
|
|
30
|
+
this.value = value;
|
|
31
|
+
}, 0)
|
|
32
|
+
|
|
33
|
+
setTimeout(() => {
|
|
34
|
+
this.sw = true;
|
|
35
|
+
}, 0)
|
|
36
|
+
}
|
|
23
37
|
|
|
24
38
|
async onInitRender(param: any, rawSet: RawSet) {
|
|
25
39
|
await super.onInitRender(param, rawSet);
|
|
@@ -32,7 +46,7 @@ export namespace This {
|
|
|
32
46
|
onChangeAttrRender(name: string, value: any, other: OtherData) {
|
|
33
47
|
super.onChangeAttrRender(name, value, other);
|
|
34
48
|
if (this.equalsAttributeName(name, 'value')) {
|
|
35
|
-
this.value
|
|
49
|
+
this.setValue(value);
|
|
36
50
|
}
|
|
37
51
|
if (this.equalsAttributeName(name, 'if')) {
|
|
38
52
|
this.if = value;
|
|
@@ -42,9 +56,26 @@ export namespace This {
|
|
|
42
56
|
}
|
|
43
57
|
}
|
|
44
58
|
|
|
45
|
-
created(component: any) {
|
|
46
|
-
component ??= this.value?.obj;
|
|
47
|
-
this.
|
|
59
|
+
created($component: any, $rawSet: RawSet) {
|
|
60
|
+
this.childObject = $component ??= this.value?.obj;
|
|
61
|
+
this.childRawSet = $rawSet;
|
|
62
|
+
|
|
63
|
+
if ($component) {
|
|
64
|
+
this.getAttribute('onCreated')?.($component);
|
|
65
|
+
|
|
66
|
+
// attribute 전달 처리
|
|
67
|
+
if (isOnChangeAttrRender($component)) {
|
|
68
|
+
this.getAttributeNames()
|
|
69
|
+
.filter(it => it.startsWith('attribute-'))
|
|
70
|
+
.forEach(it => {
|
|
71
|
+
const attrName = it.replace(/^attribute-/, '');
|
|
72
|
+
const attrValue = this.getAttribute(it as any);
|
|
73
|
+
$rawSet.dataSet.render.attribute ??= {};
|
|
74
|
+
$rawSet.dataSet.render.attribute[attrName] = attrValue;
|
|
75
|
+
$component.onChangeAttrRender(attrName, attrValue, {rawSet: $rawSet});
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
48
79
|
}
|
|
49
80
|
}
|
|
50
81
|
}
|
|
@@ -54,7 +85,11 @@ export default {
|
|
|
54
85
|
return RawSet.createComponentTargetElement({
|
|
55
86
|
name: This.selector,
|
|
56
87
|
template:
|
|
57
|
-
|
|
88
|
+
`
|
|
89
|
+
<dr-if value="\${@this@.sw}$">
|
|
90
|
+
<div dr-this="@this@.value" dr-detect-option-if="@this@?.value && @this@?.if" dr-option-strip="true" dr-on-create:arguments="@this@.createArguments" dr-on-create:callback="@this@?.created?.($component, $rawSet)">#innerHTML#</div>
|
|
91
|
+
</dr-if>
|
|
92
|
+
`,
|
|
58
93
|
objFactory: (e, o, r2, counstructorParam) => {
|
|
59
94
|
return DomRender.run({ rootObject: new This.This(...counstructorParam), config: config });
|
|
60
95
|
}
|
|
@@ -1,27 +1,30 @@
|
|
|
1
1
|
import { ValidUtils } from '@dooboostore/core/valid/ValidUtils';
|
|
2
|
+
import {ReflectUtils} from "@dooboostore/core/reflect/ReflectUtils";
|
|
2
3
|
|
|
3
4
|
export const DomRenderNoProxyKey = 'DomRender:NoProxy'
|
|
4
5
|
export const DomRenderNoProxy = (target: any, propertyKey?: string | symbol) => {
|
|
6
|
+
ReflectUtils.defineMetadata(DomRenderNoProxyKey, true, target, propertyKey);
|
|
5
7
|
// 클래스 데코레이터로 사용된 경우
|
|
6
|
-
if (propertyKey === undefined) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
// 프로퍼티 데코레이터로 사용된 경우
|
|
13
|
-
// target은 프로토타입, propertyKey는 프로퍼티 이름
|
|
14
|
-
Reflect.defineMetadata(DomRenderNoProxyKey, true, target, propertyKey);
|
|
8
|
+
// if (propertyKey === undefined) {
|
|
9
|
+
// // target은 클래스 생성자
|
|
10
|
+
// Reflect.defineMetadata(DomRenderNoProxyKey, true, target);
|
|
11
|
+
// return;
|
|
12
|
+
// }
|
|
13
|
+
//
|
|
14
|
+
// // 프로퍼티 데코레이터로 사용된 경우
|
|
15
|
+
// // target은 프로토타입, propertyKey는 프로퍼티 이름
|
|
16
|
+
// Reflect.defineMetadata(DomRenderNoProxyKey, true, target, propertyKey);
|
|
15
17
|
};
|
|
16
18
|
|
|
17
19
|
export const getDomRenderNoProxy = (target: any, propertyKey?: string | symbol) => {
|
|
18
20
|
// if (ValidUtils.isNotNullUndefined(target)) {
|
|
21
|
+
return ReflectUtils.getMetadata(DomRenderNoProxyKey, target, propertyKey);
|
|
19
22
|
// 클래스 데코레이터
|
|
20
|
-
if (propertyKey === undefined) {
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
// 프로퍼티 데코레이터
|
|
24
|
-
return Reflect.getMetadata(DomRenderNoProxyKey, target, propertyKey);
|
|
23
|
+
// if (propertyKey === undefined) {
|
|
24
|
+
// return Reflect.getMetadata(DomRenderNoProxyKey, target);
|
|
25
|
+
// }
|
|
26
|
+
// // 프로퍼티 데코레이터
|
|
27
|
+
// return Reflect.getMetadata(DomRenderNoProxyKey, target, propertyKey);
|
|
25
28
|
// } else {
|
|
26
29
|
// return undefined;
|
|
27
30
|
// }
|
|
@@ -2,7 +2,6 @@ import { DomRenderConfig } from '../configs/DomRenderConfig';
|
|
|
2
2
|
import { ScriptUtils } from '@dooboostore/core-web/script/ScriptUtils';
|
|
3
3
|
import { ElementUtils } from '@dooboostore/core-web/element/ElementUtils';
|
|
4
4
|
import { Range } from '../iterators/Range';
|
|
5
|
-
import { DomRenderFinalProxy } from '../types/Types';
|
|
6
5
|
import { getDomRenderConfig } from '../DomRenderProxy';
|
|
7
6
|
import { ObjectUtils } from '@dooboostore/core/object/ObjectUtils';
|
|
8
7
|
|
|
@@ -15,7 +14,8 @@ type HandlerInfo = {
|
|
|
15
14
|
};
|
|
16
15
|
export type NormalAttrDataType = {
|
|
17
16
|
originalAttrValue: string;
|
|
18
|
-
|
|
17
|
+
isStringTemplate: boolean;
|
|
18
|
+
variablePaths: { origin: string, inner: string }[];
|
|
19
19
|
}
|
|
20
20
|
export class EventManager {
|
|
21
21
|
public static readonly attrPrefix = 'dr-';
|
|
@@ -49,11 +49,11 @@ export class EventManager {
|
|
|
49
49
|
|
|
50
50
|
// link는 쓰지 않는걸 추천한다 라이프 사이클 꼬인다 다른 프레임워크에서도 양방향은 지양 한다
|
|
51
51
|
public static linkAttrs = [
|
|
52
|
-
{name: EventManager.attrPrefix + 'value-link', property: 'value', event: 'input'},
|
|
53
|
-
{name: EventManager.attrPrefix + 'hidden-link', property: 'value', event: 'input'},
|
|
54
|
-
{name: EventManager.attrPrefix + 'required-link', property: 'value', event: 'input'},
|
|
55
|
-
{name: EventManager.attrPrefix + 'checked-link', property: 'checked', event: 'change'},
|
|
56
|
-
{name: EventManager.attrPrefix + 'open-link', property: 'open', event: 'toggle'},
|
|
52
|
+
{ name: EventManager.attrPrefix + 'value-link', property: 'value', event: 'input' },
|
|
53
|
+
{ name: EventManager.attrPrefix + 'hidden-link', property: 'value', event: 'input' },
|
|
54
|
+
{ name: EventManager.attrPrefix + 'required-link', property: 'value', event: 'input' },
|
|
55
|
+
{ name: EventManager.attrPrefix + 'checked-link', property: 'checked', event: 'change' },
|
|
56
|
+
{ name: EventManager.attrPrefix + 'open-link', property: 'open', event: 'toggle' },
|
|
57
57
|
]
|
|
58
58
|
// @ts-ignore 합성이벤트(Synthetic) 처리하면서 의미가 없어졌다
|
|
59
59
|
public static readonly linkTargetMapAttrName = EventManager.attrPrefix + 'link-variables';
|
|
@@ -147,19 +147,19 @@ export class EventManager {
|
|
|
147
147
|
});
|
|
148
148
|
|
|
149
149
|
const rootElement = this.window.document;
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
150
|
+
const listeningEvents = new Set<string>();
|
|
151
|
+
this.eventNames.forEach(eventName => {
|
|
152
|
+
if (this.directAttachEvents.has(eventName)) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const delegatedEventName = this.delegatableEventMap[eventName] || eventName;
|
|
156
156
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
157
|
+
if (listeningEvents.has(delegatedEventName)) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
listeningEvents.add(delegatedEventName);
|
|
161
|
+
rootElement.addEventListener(delegatedEventName, this.handleEvent.bind(this), true);
|
|
162
|
+
});
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
165
|
|
|
@@ -182,7 +182,7 @@ export class EventManager {
|
|
|
182
182
|
|
|
183
183
|
private collectHandlers(event: Event): HandlerInfo[] {
|
|
184
184
|
const handlers: HandlerInfo[] = [];
|
|
185
|
-
const root =
|
|
185
|
+
const root = this.window.document;
|
|
186
186
|
if (!root) return handlers;
|
|
187
187
|
|
|
188
188
|
const initialTarget = event.target as Node;
|
|
@@ -255,7 +255,7 @@ export class EventManager {
|
|
|
255
255
|
|
|
256
256
|
private findComponentInstance(element: HTMLElement | null): any {
|
|
257
257
|
let current = element;
|
|
258
|
-
const root =
|
|
258
|
+
const root = this.window.document;
|
|
259
259
|
while (current) {
|
|
260
260
|
if ((current as any).obj) {
|
|
261
261
|
return (current as any).obj;
|
|
@@ -286,7 +286,7 @@ export class EventManager {
|
|
|
286
286
|
}
|
|
287
287
|
|
|
288
288
|
private executeHandler(event: Event, handler: HandlerInfo, componentInstance: any) {
|
|
289
|
-
const {element, type, attr} = handler;
|
|
289
|
+
const { element, type, attr } = handler;
|
|
290
290
|
const config = getDomRenderConfig(componentInstance);
|
|
291
291
|
|
|
292
292
|
switch (type) {
|
|
@@ -311,7 +311,7 @@ export class EventManager {
|
|
|
311
311
|
let value = (element as any)[handler.property];
|
|
312
312
|
|
|
313
313
|
if (mapScript) {
|
|
314
|
-
const context = this.createExecutionContext(event, element, bindObj, config, {value});
|
|
314
|
+
const context = this.createExecutionContext(event, element, bindObj, config, { value });
|
|
315
315
|
value = ScriptUtils.evaluate(`return ${mapScript}`, context);
|
|
316
316
|
}
|
|
317
317
|
|
|
@@ -370,20 +370,22 @@ export class EventManager {
|
|
|
370
370
|
params[k.slice(prefix.length)] = v;
|
|
371
371
|
});
|
|
372
372
|
|
|
373
|
-
const paramContext = this.createExecutionContext(event, element, componentInstance, config, {params});
|
|
373
|
+
const paramContext = this.createExecutionContext(event, element, componentInstance, config, { params });
|
|
374
374
|
ScriptUtils.evaluate(`${this.getBindScript(config)} ${paramScript}`, paramContext);
|
|
375
375
|
break;
|
|
376
376
|
}
|
|
377
377
|
}
|
|
378
378
|
|
|
379
379
|
public findAttrElements(fragment: DocumentFragment | Element, config?: DomRenderConfig): Set<Element> {
|
|
380
|
+
// const t0 = performance.now();
|
|
380
381
|
const elements = new Set<Element>();
|
|
381
382
|
const addAttributes = config?.applyEvents?.map(it => it.attrName) ?? [];
|
|
382
|
-
addAttributes.concat([...EventManager.attrNames]).
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
}
|
|
383
|
+
const attrs = addAttributes.concat([...EventManager.attrNames]).filter(Boolean);
|
|
384
|
+
if (attrs.length) {
|
|
385
|
+
const selector = attrs.map(a => `[${a}]`).join(',');
|
|
386
|
+
fragment?.querySelectorAll(selector).forEach(it => elements.add(it));
|
|
387
|
+
}
|
|
388
|
+
// console.log('findAttrElements time', performance.now() - t0);
|
|
387
389
|
return elements;
|
|
388
390
|
}
|
|
389
391
|
|
|
@@ -394,131 +396,159 @@ export class EventManager {
|
|
|
394
396
|
}
|
|
395
397
|
});
|
|
396
398
|
|
|
399
|
+
// let t0 = performance.now();
|
|
397
400
|
this.procAttr<HTMLInputElement>(childNodes, EventManager.valueAttrName, (it, attribute) => {
|
|
398
401
|
const script = attribute;
|
|
399
402
|
if (script) {
|
|
400
|
-
const data =
|
|
403
|
+
const data = ObjectUtils.Script.evaluateReturn(script, obj);
|
|
401
404
|
if (it.value !== data) {
|
|
402
405
|
it.value = data;
|
|
403
406
|
}
|
|
404
407
|
}
|
|
405
408
|
});
|
|
409
|
+
// console.log('applyEvent value time', performance.now() - t0);
|
|
410
|
+
// t0 = performance.now();
|
|
406
411
|
this.procAttr<HTMLInputElement>(childNodes, EventManager.checkedAttrName, (it, attribute) => {
|
|
407
412
|
const script = attribute;
|
|
408
413
|
if (script) {
|
|
409
|
-
const data =
|
|
410
|
-
if (it.checked!== data) {
|
|
414
|
+
const data = ObjectUtils.Script.evaluateReturn(script, obj);
|
|
415
|
+
if (it.checked !== data) {
|
|
411
416
|
it.checked = data;
|
|
412
417
|
}
|
|
413
418
|
}
|
|
414
419
|
});
|
|
420
|
+
// console.log('applyEvent value time', performance.now() - t0);
|
|
421
|
+
// t0 = performance.now();
|
|
415
422
|
this.procAttr<HTMLOptionElement>(childNodes, EventManager.selectedAttrName, (it, attribute) => {
|
|
416
423
|
const script = attribute;
|
|
417
424
|
if (script) {
|
|
418
|
-
const data =
|
|
419
|
-
if (it.selected!== data) {
|
|
425
|
+
const data = ObjectUtils.Script.evaluateReturn(script, obj);
|
|
426
|
+
if (it.selected !== data) {
|
|
420
427
|
it.selected = data;
|
|
421
428
|
}
|
|
422
429
|
}
|
|
423
430
|
});
|
|
431
|
+
// console.log('applyEvent value time', performance.now() - t0);
|
|
432
|
+
// t0 = performance.now();
|
|
424
433
|
this.procAttr<HTMLInputElement>(childNodes, EventManager.readonlyAttrName, (it, attribute) => {
|
|
425
434
|
const script = attribute;
|
|
426
435
|
if (script) {
|
|
427
|
-
const data =
|
|
428
|
-
if (it.readOnly!== data) {
|
|
436
|
+
const data = ObjectUtils.Script.evaluateReturn(script, obj);
|
|
437
|
+
if (it.readOnly !== data) {
|
|
429
438
|
it.readOnly = data;
|
|
430
439
|
}
|
|
431
440
|
}
|
|
432
441
|
});
|
|
442
|
+
// console.log('applyEvent value time', performance.now() - t0);
|
|
443
|
+
// t0 = performance.now();
|
|
433
444
|
this.procAttr<HTMLInputElement>(childNodes, EventManager.disabledAttrName, (it, attribute) => {
|
|
434
445
|
const script = attribute;
|
|
435
446
|
if (script) {
|
|
436
|
-
const data =
|
|
437
|
-
if (it.disabled!== data) {
|
|
447
|
+
const data = ObjectUtils.Script.evaluateReturn(script, obj);
|
|
448
|
+
if (it.disabled !== data) {
|
|
438
449
|
it.disabled = data;
|
|
439
450
|
}
|
|
440
451
|
}
|
|
441
452
|
});
|
|
453
|
+
// console.log('applyEvent value time', performance.now() - t0);
|
|
454
|
+
// t0 = performance.now();
|
|
442
455
|
this.procAttr<HTMLElement>(childNodes, EventManager.hiddenAttrName, (it, attribute) => {
|
|
443
456
|
const script = attribute;
|
|
444
457
|
if (script) {
|
|
445
|
-
const data =
|
|
446
|
-
if (it.hidden!== data) {
|
|
458
|
+
const data = ObjectUtils.Script.evaluateReturn(script, obj);
|
|
459
|
+
if (it.hidden !== data) {
|
|
447
460
|
it.hidden = data;
|
|
448
461
|
}
|
|
449
462
|
}
|
|
450
463
|
});
|
|
464
|
+
// console.log('applyEvent value time', performance.now() - t0);
|
|
465
|
+
// t0 = performance.now();
|
|
451
466
|
this.procAttr<HTMLInputElement>(childNodes, EventManager.requiredAttrName, (it, attribute) => {
|
|
452
467
|
const script = attribute;
|
|
453
468
|
if (script) {
|
|
454
|
-
const data =
|
|
455
|
-
if (it.required!== data) {
|
|
469
|
+
const data = ObjectUtils.Script.evaluateReturn(script, obj);
|
|
470
|
+
if (it.required !== data) {
|
|
456
471
|
it.required = data;
|
|
457
472
|
}
|
|
458
473
|
}
|
|
459
474
|
});
|
|
475
|
+
// console.log('applyEvent value time', performance.now() - t0);
|
|
476
|
+
// t0 = performance.now();
|
|
460
477
|
this.procAttr<HTMLDialogElement>(childNodes, EventManager.openAttrName, (it, attribute) => {
|
|
461
478
|
const script = attribute;
|
|
462
479
|
if (script) {
|
|
463
|
-
const data =
|
|
464
|
-
if (it.open!== data) {
|
|
480
|
+
const data = ObjectUtils.Script.evaluateReturn(script, obj);
|
|
481
|
+
if (it.open !== data) {
|
|
465
482
|
it.open = data;
|
|
466
483
|
}
|
|
467
484
|
}
|
|
468
485
|
});
|
|
469
|
-
|
|
486
|
+
// console.log('applyEvent value time', performance.now() - t0);
|
|
487
|
+
// t0 = performance.now();
|
|
470
488
|
this.procAttr(childNodes, EventManager.normalAttrMapAttrName, (it, attribute) => {
|
|
471
489
|
const map = new Map<string, NormalAttrDataType>(JSON.parse(attribute));
|
|
472
490
|
map.forEach((v, k) => {
|
|
473
491
|
|
|
474
492
|
const variablePaths = v.variablePaths;
|
|
475
493
|
let targetScript = v.originalAttrValue;//typeof v.originalAttrValue === 'string' ? JSON.parse(v.originalAttrValue) : v.originalAttrValue;
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
494
|
+
let script: string;
|
|
495
|
+
if (v.isStringTemplate) {
|
|
496
|
+
variablePaths.forEach(it => {
|
|
497
|
+
let r = ObjectUtils.Path.toOptionalChainPath(it.inner);
|
|
498
|
+
targetScript = targetScript.replaceAll(it.origin, `\${${r}}`);
|
|
499
|
+
})
|
|
500
|
+
script = '`' + targetScript + '`';
|
|
501
|
+
} else {
|
|
502
|
+
variablePaths.forEach(it => {
|
|
503
|
+
let r = ObjectUtils.Path.toOptionalChainPath(it.inner);
|
|
504
|
+
targetScript = targetScript.replaceAll(it.origin, `${r}`);
|
|
505
|
+
})
|
|
506
|
+
script = targetScript;
|
|
507
|
+
}
|
|
508
|
+
const data = ObjectUtils.Script.evaluate(`const $element = this.element; return ${script}`, Object.assign(obj, {
|
|
481
509
|
__render: Object.freeze({
|
|
482
510
|
element: it,
|
|
483
511
|
attribute: ElementUtils.getAttributeToObject(it)
|
|
484
512
|
})
|
|
485
513
|
}));
|
|
486
|
-
|
|
514
|
+
// console.log('!!!!!!!!!!!', k, data, script, variablePaths, v)
|
|
515
|
+
if (data === null || data === undefined) {
|
|
487
516
|
it.removeAttribute(k);
|
|
488
517
|
} else {
|
|
489
518
|
it.setAttribute(k, data);
|
|
490
519
|
}
|
|
491
520
|
});
|
|
492
521
|
});
|
|
522
|
+
// console.log('applyEvent value time', performance.now() - t0);
|
|
523
|
+
// t0 = performance.now();
|
|
493
524
|
|
|
494
525
|
EventManager.WINDOW_EVENTS.forEach(it => {
|
|
495
526
|
this.procAttr<HTMLInputElement>(childNodes, EventManager.attrPrefix + 'window-event-' + it, (it, attribute) => {
|
|
496
527
|
(it as any).obj = obj;
|
|
497
528
|
});
|
|
498
529
|
});
|
|
499
|
-
|
|
530
|
+
// console.log('applyEvent value time', performance.now() - t0);
|
|
531
|
+
// t0 = performance.now();
|
|
500
532
|
EventManager.linkAttrs.forEach(linkInfo => {
|
|
501
533
|
this.procAttr<HTMLElement>(childNodes, linkInfo.name, (it, varName) => {
|
|
502
|
-
|
|
503
|
-
// console.log('ink??????????')
|
|
504
534
|
if (varName) {
|
|
505
535
|
const ownerVariablePathName = it.getAttribute(EventManager.ownerVariablePathAttrName);
|
|
506
536
|
const mapScript = it.getAttribute(`${linkInfo.name}:map`);
|
|
507
537
|
let bindObj = obj;
|
|
508
538
|
if (ownerVariablePathName) {
|
|
509
|
-
bindObj =
|
|
539
|
+
bindObj = ObjectUtils.Script.evaluateReturn(ownerVariablePathName, obj);
|
|
510
540
|
}
|
|
511
541
|
const getValue = this.getValue(obj, varName, bindObj);
|
|
512
542
|
if (typeof getValue === 'function' && getValue) {
|
|
513
543
|
let setValue = (it as any)[linkInfo.property];
|
|
514
544
|
if (mapScript) {
|
|
515
|
-
setValue =
|
|
545
|
+
setValue = ObjectUtils.Script.evaluate(`${this.getBindScript(config)} return ${mapScript}`, Object.assign(bindObj, { __render: Object.freeze({ element: it, target: bindObj, range: Range.range, value: setValue, scripts: EventManager.setBindProperty(config?.scripts, obj), ...config?.eventVariables }) }));
|
|
516
546
|
}
|
|
517
547
|
getValue(setValue);
|
|
518
548
|
} else if (getValue) {
|
|
519
549
|
let setValue = getValue;
|
|
520
550
|
if (mapScript) {
|
|
521
|
-
setValue =
|
|
551
|
+
setValue = ObjectUtils.Script.evaluate(`${this.getBindScript(config)} return ${mapScript}`, Object.assign(bindObj, { __render: Object.freeze({ element: it, target: bindObj, range: Range.range, value: setValue, scripts: EventManager.setBindProperty(config?.scripts, obj), ...config?.eventVariables }) }));
|
|
522
552
|
}
|
|
523
553
|
if (setValue === null) {
|
|
524
554
|
it.removeAttribute(linkInfo.property);
|
|
@@ -531,7 +561,8 @@ export class EventManager {
|
|
|
531
561
|
}
|
|
532
562
|
});
|
|
533
563
|
});
|
|
534
|
-
|
|
564
|
+
// console.log('applyEvent value time', performance.now() - t0);
|
|
565
|
+
// t0 = performance.now();
|
|
535
566
|
this.directAttachEvents.forEach(eventName => {
|
|
536
567
|
const attr = `${EventManager.attrPrefix}event-${eventName}`;
|
|
537
568
|
this.procAttr<HTMLElement>(childNodes, attr, (element, script) => {
|
|
@@ -543,24 +574,25 @@ export class EventManager {
|
|
|
543
574
|
const filterScript = element.getAttribute(`${attr}:filter`);
|
|
544
575
|
let filter = true;
|
|
545
576
|
if (filterScript) {
|
|
546
|
-
filter =
|
|
577
|
+
filter = ObjectUtils.Script.evaluate<boolean>(`${this.getBindScript(config)} return ${filterScript}`, context) ?? false;
|
|
547
578
|
}
|
|
548
579
|
if (filter) {
|
|
549
|
-
|
|
580
|
+
ObjectUtils.Script.evaluate(`${this.getBindScript(config)} ${script}`, context);
|
|
550
581
|
}
|
|
551
582
|
};
|
|
552
583
|
element.addEventListener(eventName, handler);
|
|
553
584
|
// TODO: Add logic to remove this listener when the element is destroyed.
|
|
554
585
|
});
|
|
555
586
|
});
|
|
556
|
-
|
|
587
|
+
// console.log('applyEvent value time', performance.now() - t0);
|
|
588
|
+
// t0 = performance.now();
|
|
557
589
|
this.procAttr<HTMLElement>(childNodes, EventManager.onInitAttrName, (it, attribute) => {
|
|
558
590
|
let script = attribute;
|
|
559
591
|
if (script) {
|
|
560
592
|
script = 'return ' + script;
|
|
561
593
|
}
|
|
562
594
|
if (script) {
|
|
563
|
-
|
|
595
|
+
ObjectUtils.Script.evaluate(`${this.getBindScript(config)}; ${script} `, Object.assign(obj, {
|
|
564
596
|
__render: Object.freeze({
|
|
565
597
|
element: it,
|
|
566
598
|
attribute: ElementUtils.getAttributeToObject(it),
|
|
@@ -569,7 +601,8 @@ export class EventManager {
|
|
|
569
601
|
}));
|
|
570
602
|
}
|
|
571
603
|
});
|
|
572
|
-
|
|
604
|
+
// console.log('applyEvent value time', performance.now() - t0);
|
|
605
|
+
// t0 = performance.now();
|
|
573
606
|
this.onRenderedEvent(obj, childNodes, config);
|
|
574
607
|
this.changeVar(obj, childNodes, undefined, config);
|
|
575
608
|
const elements = Array.from(childNodes).filter(it => it.nodeType === 1).map(it => it as Element);
|
|
@@ -588,7 +621,7 @@ export class EventManager {
|
|
|
588
621
|
script = 'return ' + script;
|
|
589
622
|
}
|
|
590
623
|
if (script) {
|
|
591
|
-
|
|
624
|
+
ObjectUtils.Script.evaluate(`${this.getBindScript(config)}; ${script} `, Object.assign(obj, {
|
|
592
625
|
__render: Object.freeze({
|
|
593
626
|
element: it,
|
|
594
627
|
attribute: ElementUtils.getAttributeToObject(it),
|
|
@@ -601,27 +634,40 @@ export class EventManager {
|
|
|
601
634
|
|
|
602
635
|
public changeVar(obj: any, elements: Set<Element> | Set<ChildNode>, varName?: string, config?: DomRenderConfig) {
|
|
603
636
|
// console.log('changeVar', obj, elements, varName)
|
|
604
|
-
this.procAttr(elements, EventManager.styleAttrName, (it, attribute) => {
|
|
637
|
+
this.procAttr(elements, EventManager.styleAttrName, (it: HTMLElement, attribute) => {
|
|
605
638
|
let script = attribute;
|
|
606
639
|
if (script) {
|
|
607
640
|
script = 'return ' + script;
|
|
608
641
|
}
|
|
609
642
|
if (EventManager.isUsingThisVar(script, varName) || varName === undefined) {
|
|
610
|
-
const data =
|
|
643
|
+
const data = ObjectUtils.Script.evaluate(`const $element = this.__render.element; ${script} `, Object.assign(obj, {
|
|
611
644
|
__render: Object.freeze({
|
|
612
645
|
element: it,
|
|
613
646
|
attribute: ElementUtils.getAttributeToObject(it)
|
|
614
647
|
})
|
|
615
648
|
}));
|
|
616
649
|
if (typeof data === 'string') {
|
|
617
|
-
|
|
650
|
+
data.split(';').forEach(sit => {
|
|
651
|
+
const [key, value] = sit.split(':').map(s => s.trim());
|
|
652
|
+
if (key && value) {
|
|
653
|
+
(it.style as any)[key] = value;
|
|
654
|
+
}
|
|
655
|
+
})
|
|
656
|
+
// it.setAttribute('style', data);
|
|
618
657
|
} else if (Array.isArray(data)) {
|
|
619
|
-
|
|
658
|
+
data.forEach(sit => {
|
|
659
|
+
const [key, value] = sit.split(':').map(s => s.trim());
|
|
660
|
+
if (key && value) {
|
|
661
|
+
(it.style as any)[key] = value;
|
|
662
|
+
}
|
|
663
|
+
})
|
|
664
|
+
|
|
665
|
+
// it.setAttribute('style', data.join(';'));
|
|
620
666
|
} else {
|
|
621
667
|
for (const [key, value] of Object.entries(data)) {
|
|
622
|
-
if (it instanceof HTMLElement) {
|
|
623
|
-
|
|
624
|
-
}
|
|
668
|
+
// if (it instanceof HTMLElement) {
|
|
669
|
+
(it.style as any)[key] = value === null ? null : String(value);
|
|
670
|
+
// }
|
|
625
671
|
}
|
|
626
672
|
}
|
|
627
673
|
}
|
|
@@ -633,30 +679,87 @@ export class EventManager {
|
|
|
633
679
|
script = 'return ' + script;
|
|
634
680
|
}
|
|
635
681
|
if (EventManager.isUsingThisVar(script, varName) || varName === undefined) {
|
|
636
|
-
const data =
|
|
682
|
+
const data = ObjectUtils.Script.evaluate(`const $element = this.element; ${script} `, Object.assign(obj, {
|
|
637
683
|
__render: Object.freeze({
|
|
638
684
|
element: it,
|
|
639
685
|
attribute: ElementUtils.getAttributeToObject(it)
|
|
640
686
|
})
|
|
641
687
|
}));
|
|
642
688
|
|
|
689
|
+
// alert(1)
|
|
643
690
|
if (typeof data === 'string') {
|
|
644
|
-
|
|
691
|
+
data.split(' ').forEach(cit => it.classList.add(cit.trim()));
|
|
645
692
|
} else if (Array.isArray(data)) {
|
|
646
|
-
|
|
693
|
+
data.forEach(cit => it.classList.add(cit.trim()));
|
|
647
694
|
} else {
|
|
648
695
|
for (const [key, value] of Object.entries(data)) {
|
|
649
696
|
if (it instanceof HTMLElement) {
|
|
650
697
|
if (value) {
|
|
651
|
-
it.classList.add(key);
|
|
698
|
+
it.classList.add(key.trim());
|
|
652
699
|
} else {
|
|
653
|
-
it.classList.remove(key);
|
|
700
|
+
it.classList.remove(key.trim());
|
|
654
701
|
}
|
|
655
702
|
}
|
|
656
703
|
}
|
|
657
704
|
}
|
|
658
705
|
}
|
|
659
706
|
});
|
|
707
|
+
|
|
708
|
+
this.procAttr<HTMLInputElement>(elements, EventManager.valueAttrName, (it, attribute) => {
|
|
709
|
+
if (EventManager.isUsingThisVar(attribute, varName) || varName === undefined) {
|
|
710
|
+
const data = ObjectUtils.Script.evaluateReturn(attribute, obj);
|
|
711
|
+
if (it.value !== data) it.value = data;
|
|
712
|
+
}
|
|
713
|
+
});
|
|
714
|
+
|
|
715
|
+
this.procAttr<HTMLInputElement>(elements, EventManager.checkedAttrName, (it, attribute) => {
|
|
716
|
+
if (EventManager.isUsingThisVar(attribute, varName) || varName === undefined) {
|
|
717
|
+
const data = ObjectUtils.Script.evaluateReturn(attribute, obj);
|
|
718
|
+
if (it.checked !== data) it.checked = data;
|
|
719
|
+
}
|
|
720
|
+
});
|
|
721
|
+
|
|
722
|
+
this.procAttr<HTMLOptionElement>(elements, EventManager.selectedAttrName, (it, attribute) => {
|
|
723
|
+
if (EventManager.isUsingThisVar(attribute, varName) || varName === undefined) {
|
|
724
|
+
const data = ObjectUtils.Script.evaluateReturn(attribute, obj);
|
|
725
|
+
if (it.selected !== data) it.selected = data;
|
|
726
|
+
}
|
|
727
|
+
});
|
|
728
|
+
|
|
729
|
+
this.procAttr<HTMLInputElement>(elements, EventManager.readonlyAttrName, (it, attribute) => {
|
|
730
|
+
if (EventManager.isUsingThisVar(attribute, varName) || varName === undefined) {
|
|
731
|
+
const data = ObjectUtils.Script.evaluateReturn(attribute, obj);
|
|
732
|
+
if (it.readOnly !== data) it.readOnly = data;
|
|
733
|
+
}
|
|
734
|
+
});
|
|
735
|
+
|
|
736
|
+
this.procAttr<HTMLInputElement>(elements, EventManager.disabledAttrName, (it, attribute) => {
|
|
737
|
+
if (EventManager.isUsingThisVar(attribute, varName) || varName === undefined) {
|
|
738
|
+
const data = ObjectUtils.Script.evaluateReturn(attribute, obj);
|
|
739
|
+
if (it.disabled !== data) it.disabled = data;
|
|
740
|
+
}
|
|
741
|
+
});
|
|
742
|
+
|
|
743
|
+
this.procAttr<HTMLElement>(elements, EventManager.hiddenAttrName, (it, attribute) => {
|
|
744
|
+
if (EventManager.isUsingThisVar(attribute, varName) || varName === undefined) {
|
|
745
|
+
const data = ObjectUtils.Script.evaluateReturn(attribute, obj);
|
|
746
|
+
if (it.hidden !== data) it.hidden = data;
|
|
747
|
+
}
|
|
748
|
+
});
|
|
749
|
+
|
|
750
|
+
this.procAttr<HTMLInputElement>(elements, EventManager.requiredAttrName, (it, attribute) => {
|
|
751
|
+
if (EventManager.isUsingThisVar(attribute, varName) || varName === undefined) {
|
|
752
|
+
const data = ObjectUtils.Script.evaluateReturn(attribute, obj);
|
|
753
|
+
if (it.required !== data) it.required = data;
|
|
754
|
+
}
|
|
755
|
+
});
|
|
756
|
+
|
|
757
|
+
this.procAttr<HTMLDialogElement>(elements, EventManager.openAttrName, (it, attribute) => {
|
|
758
|
+
if (EventManager.isUsingThisVar(attribute, varName) || varName === undefined) {
|
|
759
|
+
const data = ObjectUtils.Script.evaluateReturn(attribute, obj);
|
|
760
|
+
if (it.open !== data) it.open = data;
|
|
761
|
+
}
|
|
762
|
+
});
|
|
660
763
|
}
|
|
661
764
|
|
|
662
765
|
public procAttr<T extends Element = Element>(elements: Set<Element> | Set<ChildNode> | Node[] = new Set(), attrName: string, callBack: (h: T, value: string, attributes: any) => void) {
|
|
@@ -708,7 +811,7 @@ export class EventManager {
|
|
|
708
811
|
// raws = raws!.replace(RegExp(it.replace('$', '\\$'), 'g'), `this?.___${it}`);
|
|
709
812
|
raws = raws!.replace(RegExp(it.replace('$', '\\$'), 'g'), `this.___${it}`);
|
|
710
813
|
});
|
|
711
|
-
const variablePaths = ObjectUtils.Path.detectPathFromScript(raws ?? '', {excludeThis: true});
|
|
814
|
+
const variablePaths = ObjectUtils.Path.detectPathFromScript(raws ?? '', { excludeThis: true });
|
|
712
815
|
return variablePaths.has(varName);
|
|
713
816
|
}
|
|
714
817
|
return false;
|
|
@@ -4,7 +4,7 @@ export type OtherData = {
|
|
|
4
4
|
rawSet?: RawSet
|
|
5
5
|
}
|
|
6
6
|
export interface OnChangeAttrRender {
|
|
7
|
-
onChangeAttrRender(name: string, value: any, other
|
|
7
|
+
onChangeAttrRender(name: string, value: any, other?: OtherData): void;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export const isOnChangeAttrRender = (obj: any): obj is OnChangeAttrRender => {
|