dom-render 1.0.79 → 1.0.82

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.
@@ -105,7 +105,8 @@ var EventManager = /** @class */ (function () {
105
105
  map.forEach(function (v, k) {
106
106
  var data = ScriptUtils_1.ScriptUtils.eval("const $element = this.element; return ".concat(v, " "), Object.assign(obj, {
107
107
  __render: Object.freeze({
108
- element: it
108
+ element: it,
109
+ attribute: DomUtils_1.DomUtils.getAttributeToObject(it)
109
110
  })
110
111
  }));
111
112
  it.setAttribute(k, data);
@@ -117,26 +118,6 @@ var EventManager = /** @class */ (function () {
117
118
  it.obj = obj;
118
119
  });
119
120
  });
120
- // on-init event
121
- this.procAttr(childNodes, EventManager.onInitAttrName, function (it, attribute) {
122
- var script = attribute;
123
- if (script) {
124
- script = 'return ' + script;
125
- }
126
- if (script) {
127
- ScriptUtils_1.ScriptUtils.eval("".concat(_this.bindScript, "; ").concat(script, " "), Object.assign(obj, {
128
- __render: Object.freeze({
129
- element: it
130
- })
131
- }));
132
- // console.log('onInit--->', obj, varName, it)
133
- // if (typeof this.getValue(obj, varName) === 'function') {
134
- // this.getValue(obj, varName)(it);
135
- // } else {
136
- // this.setValue(obj, varName, it);
137
- // }
138
- }
139
- });
140
121
  // value-link event
141
122
  this.procAttr(childNodes, EventManager.valueLinkAttrName, function (it, varName) {
142
123
  if (varName) {
@@ -185,6 +166,7 @@ var EventManager = /** @class */ (function () {
185
166
  __render: Object.freeze({
186
167
  event: event,
187
168
  element: it,
169
+ attribute: DomUtils_1.DomUtils.getAttributeToObject(it),
188
170
  target: event.target,
189
171
  range: Range_1.Range.range,
190
172
  scripts: EventManager.setBindProperty(config === null || config === void 0 ? void 0 : config.scripts, obj)
@@ -200,6 +182,27 @@ var EventManager = /** @class */ (function () {
200
182
  });
201
183
  }
202
184
  });
185
+ // on-init event
186
+ this.procAttr(childNodes, EventManager.onInitAttrName, function (it, attribute) {
187
+ var script = attribute;
188
+ if (script) {
189
+ script = 'return ' + script;
190
+ }
191
+ if (script) {
192
+ ScriptUtils_1.ScriptUtils.eval("".concat(_this.bindScript, "; ").concat(script, " "), Object.assign(obj, {
193
+ __render: Object.freeze({
194
+ element: it,
195
+ attribute: DomUtils_1.DomUtils.getAttributeToObject(it)
196
+ })
197
+ }));
198
+ // console.log('onInit--->', obj, varName, it)
199
+ // if (typeof this.getValue(obj, varName) === 'function') {
200
+ // this.getValue(obj, varName)(it);
201
+ // } else {
202
+ // this.setValue(obj, varName, it);
203
+ // }
204
+ }
205
+ });
203
206
  this.changeVar(obj, childNodes, undefined, config);
204
207
  // console.log('eventManager-applyEvent-->', config?.applyEvents)
205
208
  var elements = Array.from(childNodes).filter(function (it) { return it.nodeType === 1; }).map(function (it) { return it; });
@@ -247,7 +250,8 @@ var EventManager = /** @class */ (function () {
247
250
  if (EventManager.isUsingThisVar(script, varName) || varName === undefined) {
248
251
  var data = ScriptUtils_1.ScriptUtils.eval("const $element = this.__render.element; ".concat(script, " "), Object.assign(obj, {
249
252
  __render: Object.freeze({
250
- element: it
253
+ element: it,
254
+ attribute: DomUtils_1.DomUtils.getAttributeToObject(it)
251
255
  })
252
256
  }));
253
257
  if (typeof data === 'string') {
@@ -298,7 +302,8 @@ var EventManager = /** @class */ (function () {
298
302
  if (EventManager.isUsingThisVar(script, varName) || varName === undefined) {
299
303
  var data = ScriptUtils_1.ScriptUtils.eval("const $element = this.__render.element; ".concat(script, " "), Object.assign(obj, {
300
304
  __render: Object.freeze({
301
- element: it
305
+ element: it,
306
+ attribute: DomUtils_1.DomUtils.getAttributeToObject(it)
302
307
  })
303
308
  }));
304
309
  if (typeof data === 'string') {
@@ -326,7 +331,8 @@ var EventManager = /** @class */ (function () {
326
331
  if (EventManager.isUsingThisVar(script, varName) || varName === undefined) {
327
332
  var data = ScriptUtils_1.ScriptUtils.eval("const $element = this.element; ".concat(script, " "), Object.assign(obj, {
328
333
  __render: Object.freeze({
329
- element: it
334
+ element: it,
335
+ attribute: DomUtils_1.DomUtils.getAttributeToObject(it)
330
336
  })
331
337
  }));
332
338
  if (typeof data === 'string') {
@@ -360,7 +366,8 @@ var EventManager = /** @class */ (function () {
360
366
  if (isUsing) {
361
367
  var data = ScriptUtils_1.ScriptUtils.eval("const $element = this.element; return ".concat(v, " "), Object.assign(obj, {
362
368
  __render: Object.freeze({
363
- element: it
369
+ element: it,
370
+ attribute: DomUtils_1.DomUtils.getAttributeToObject(it)
364
371
  })
365
372
  }));
366
373
  it.setAttribute(k, data);
@@ -377,14 +384,13 @@ var EventManager = /** @class */ (function () {
377
384
  it.addEventListener(eventName, function (event) {
378
385
  var filter = true;
379
386
  var filterScript = it.getAttribute("".concat(attr, ":filter"));
380
- var attribute = DomUtils_1.DomUtils.getAttributeToObject(it);
381
387
  var thisTarget = Object.assign(obj, {
382
388
  __render: Object.freeze({
383
389
  event: event,
384
390
  element: it,
385
391
  target: event.target,
386
392
  range: Range_1.Range.range,
387
- attribute: attribute,
393
+ attribute: DomUtils_1.DomUtils.getAttributeToObject(it),
388
394
  router: config === null || config === void 0 ? void 0 : config.router,
389
395
  scripts: EventManager.setBindProperty(config === null || config === void 0 ? void 0 : config.scripts, obj)
390
396
  })
@@ -420,6 +426,7 @@ var EventManager = /** @class */ (function () {
420
426
  __render: Object.freeze({
421
427
  event: event,
422
428
  element: it,
429
+ attribute: DomUtils_1.DomUtils.getAttributeToObject(it),
423
430
  target: event.target,
424
431
  range: Range_1.Range.range,
425
432
  scripts: EventManager.setBindProperty(config === null || config === void 0 ? void 0 : config.scripts, obj),
@@ -127,7 +127,7 @@ var Messenger = /** @class */ (function () {
127
127
  this.config.window.addEventListener(Messenger.EVENT_PUBLISH_KEY, function (e) {
128
128
  var _a, _b;
129
129
  var detail = e.detail;
130
- console.log('--->', detail);
130
+ // console.log('--->', detail)
131
131
  var rtns = [];
132
132
  (_a = _this.getChannels(detail.key)) === null || _a === void 0 ? void 0 : _a.forEach(function (it) {
133
133
  try {
@@ -144,7 +144,7 @@ var Messenger = /** @class */ (function () {
144
144
  });
145
145
  this.config.window.addEventListener(Messenger.EVENT_SUBSCRIBE_KEY, function (e) {
146
146
  var detail = e.detail;
147
- console.log('--->', detail);
147
+ // console.log('--->', detail)
148
148
  var channel = _this.createChannel(detail.obj, detail.key);
149
149
  detail.init(channel, channel.subscribe(detail.subscribe));
150
150
  });
@@ -170,7 +170,7 @@ var Messenger = /** @class */ (function () {
170
170
  if (obj) {
171
171
  this.channels.forEach(function (it) {
172
172
  if (it.obj === obj) {
173
- console.log('dddddddddddd', obj);
173
+ // console.log('dddddddddddd', obj)
174
174
  _this.deleteChannel(it);
175
175
  }
176
176
  });
@@ -1,7 +1,10 @@
1
- export declare class Appender {
2
- [key: number]: any[] | undefined;
1
+ export declare class Appender<T = any> implements Iterable<T> {
2
+ [key: number]: T[] | undefined;
3
3
  length: number;
4
- constructor();
5
- push(...items: any[]): void;
4
+ constructor(defaultDatas?: T[]);
5
+ [Symbol.iterator](): Iterator<T>;
6
+ getAll(): T[];
7
+ getAlls(): T[][];
8
+ push(...items: T[]): void;
6
9
  clear(): void;
7
10
  }
@@ -2,11 +2,35 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Appender = void 0;
4
4
  var Appender = /** @class */ (function () {
5
- // [keys: string]: any;
6
- function Appender() {
5
+ function Appender(defaultDatas) {
7
6
  this.length = 0;
7
+ if (defaultDatas) {
8
+ this.push.apply(this, defaultDatas);
9
+ }
8
10
  // (this.childs as any).isAppender = true;
9
11
  }
12
+ Appender.prototype[Symbol.iterator] = function () {
13
+ var items = this.getAll();
14
+ var idx = 0;
15
+ return {
16
+ next: function (value) {
17
+ var r = { value: undefined, done: true };
18
+ if (items.length > idx) {
19
+ r = { value: items[idx], done: false };
20
+ }
21
+ idx++;
22
+ return r;
23
+ }
24
+ };
25
+ };
26
+ Appender.prototype.getAll = function () {
27
+ return this.getAlls().flat();
28
+ };
29
+ Appender.prototype.getAlls = function () {
30
+ var _this = this;
31
+ var map = Array.from({ length: this.length }).filter(function (it, idx) { return _this[idx]; }).map(function (it, idx) { return _this[idx]; });
32
+ return map;
33
+ };
10
34
  Appender.prototype.push = function () {
11
35
  var items = [];
12
36
  for (var _i = 0; _i < arguments.length; _i++) {
package/operators/Dr.js CHANGED
@@ -50,7 +50,7 @@ var Dr = /** @class */ (function (_super) {
50
50
  var tempalte = this.source.config.window.document.createElement('template');
51
51
  tempalte.innerHTML = newTemp.innerHTML;
52
52
  this.returnContainer.fag.append(tempalte.content);
53
- var rr = RawSet_1.RawSet.checkPointCreates(this.returnContainer.fag, this.source.config);
53
+ var rr = RawSet_1.RawSet.checkPointCreates(this.returnContainer.fag, this.source.obj, this.source.config);
54
54
  (_c = this.elementSource.element.parentNode) === null || _c === void 0 ? void 0 : _c.replaceChild(this.returnContainer.fag, this.elementSource.element);
55
55
  (_a = this.returnContainer.raws).push.apply(_a, rr);
56
56
  return OperatorRender_1.ExecuteState.EXECUTE;
@@ -52,7 +52,7 @@ var DrAppender = /** @class */ (function (_super) {
52
52
  var tempalte = this.source.config.window.document.createElement('template');
53
53
  tempalte.innerHTML = newTemp.innerHTML;
54
54
  this.returnContainer.fag.append(tempalte.content);
55
- var rr = RawSet_1.RawSet.checkPointCreates(this.returnContainer.fag, this.source.config);
55
+ var rr = RawSet_1.RawSet.checkPointCreates(this.returnContainer.fag, this.source.obj, this.source.config);
56
56
  (_e = this.elementSource.element.parentNode) === null || _e === void 0 ? void 0 : _e.replaceChild(this.returnContainer.fag, this.elementSource.element);
57
57
  // const rrr = rr.flatMap(it => it.render(obj, config));// .flat();
58
58
  (_a = this.returnContainer.raws).push.apply(_a, rr);
@@ -50,7 +50,7 @@ var DrFor = /** @class */ (function (_super) {
50
50
  var tempalte = this.source.config.window.document.createElement('template');
51
51
  tempalte.innerHTML = newTemp.innerHTML;
52
52
  this.returnContainer.fag.append(tempalte.content);
53
- var rr = RawSet_1.RawSet.checkPointCreates(this.returnContainer.fag, this.source.config);
53
+ var rr = RawSet_1.RawSet.checkPointCreates(this.returnContainer.fag, this.source.obj, this.source.config);
54
54
  (_e = this.elementSource.element.parentNode) === null || _e === void 0 ? void 0 : _e.replaceChild(this.returnContainer.fag, this.elementSource.element);
55
55
  (_a = this.returnContainer.raws).push.apply(_a, rr);
56
56
  return OperatorRender_1.ExecuteState.EXECUTE;
@@ -52,7 +52,7 @@ var DrForOf = /** @class */ (function (_super) {
52
52
  var tempalte = this.source.config.window.document.createElement('template');
53
53
  tempalte.innerHTML = newTemp.innerHTML;
54
54
  this.returnContainer.fag.append(tempalte.content);
55
- var rr = RawSet_1.RawSet.checkPointCreates(this.returnContainer.fag, this.source.config);
55
+ var rr = RawSet_1.RawSet.checkPointCreates(this.returnContainer.fag, this.source.obj, this.source.config);
56
56
  (_e = this.elementSource.element.parentNode) === null || _e === void 0 ? void 0 : _e.replaceChild(this.returnContainer.fag, this.elementSource.element);
57
57
  // const rrr = rr.flatMap(it => it.render(obj, config));// .flat();
58
58
  (_a = this.returnContainer.raws).push.apply(_a, rr);
@@ -90,7 +90,7 @@ var DrForm = /** @class */ (function (_super) {
90
90
  }
91
91
  });
92
92
  RawSet_1.RawSet.drFormOtherMoveAttr(this.elementSource.element, 'temp-name', 'name', this.source.config);
93
- (_a = this.returnContainer.raws).push.apply(_a, RawSet_1.RawSet.checkPointCreates(this.elementSource.element, this.source.config));
93
+ (_a = this.returnContainer.raws).push.apply(_a, RawSet_1.RawSet.checkPointCreates(this.elementSource.element, this.source.obj, this.source.config));
94
94
  return OperatorRender_1.ExecuteState.EXECUTE;
95
95
  }
96
96
  return OperatorRender_1.ExecuteState.NO_EXECUTE;
package/operators/DrIf.js CHANGED
@@ -57,7 +57,7 @@ var DrIf = /** @class */ (function (_super) {
57
57
  tempalte.innerHTML = newTemp.innerHTML;
58
58
  // console.log(tempalte.innerHTML)
59
59
  this.returnContainer.fag.append(tempalte.content);
60
- var rr = RawSet_1.RawSet.checkPointCreates(this.returnContainer.fag, this.source.config);
60
+ var rr = RawSet_1.RawSet.checkPointCreates(this.returnContainer.fag, this.source.obj, this.source.config);
61
61
  (_e = this.elementSource.element.parentNode) === null || _e === void 0 ? void 0 : _e.replaceChild(this.returnContainer.fag, this.elementSource.element);
62
62
  (_a = this.returnContainer.raws).push.apply(_a, rr);
63
63
  // if (bypass) {
@@ -48,7 +48,7 @@ var DrInnerHTML = /** @class */ (function (_super) {
48
48
  var tempalte = this.source.config.window.document.createElement('template');
49
49
  tempalte.innerHTML = newTemp.innerHTML;
50
50
  this.returnContainer.fag.append(tempalte.content);
51
- var rr = RawSet_1.RawSet.checkPointCreates(this.returnContainer.fag, this.source.config);
51
+ var rr = RawSet_1.RawSet.checkPointCreates(this.returnContainer.fag, this.source.obj, this.source.config);
52
52
  (_d = this.elementSource.element.parentNode) === null || _d === void 0 ? void 0 : _d.replaceChild(this.returnContainer.fag, this.elementSource.element);
53
53
  (_a = this.returnContainer.raws).push.apply(_a, rr);
54
54
  return OperatorRender_1.ExecuteState.EXECUTE;
@@ -46,7 +46,7 @@ var DrInnerText = /** @class */ (function (_super) {
46
46
  var tempalte = this.source.config.window.document.createElement('template');
47
47
  tempalte.innerHTML = newTemp.innerHTML;
48
48
  this.returnContainer.fag.append(tempalte.content);
49
- var rr = RawSet_1.RawSet.checkPointCreates(this.returnContainer.fag, this.source.config);
49
+ var rr = RawSet_1.RawSet.checkPointCreates(this.returnContainer.fag, this.source.obj, this.source.config);
50
50
  (_d = this.elementSource.element.parentNode) === null || _d === void 0 ? void 0 : _d.replaceChild(this.returnContainer.fag, this.elementSource.element);
51
51
  (_a = this.returnContainer.raws).push.apply(_a, rr);
52
52
  return OperatorRender_1.ExecuteState.EXECUTE;
@@ -51,7 +51,7 @@ var DrRepeat = /** @class */ (function (_super) {
51
51
  var tempalte = this.source.config.window.document.createElement('template');
52
52
  tempalte.innerHTML = newTemp.innerHTML;
53
53
  this.returnContainer.fag.append(tempalte.content);
54
- var rr = RawSet_1.RawSet.checkPointCreates(this.returnContainer.fag, this.source.config);
54
+ var rr = RawSet_1.RawSet.checkPointCreates(this.returnContainer.fag, this.source.obj, this.source.config);
55
55
  (_e = this.elementSource.element.parentNode) === null || _e === void 0 ? void 0 : _e.replaceChild(this.returnContainer.fag, this.elementSource.element);
56
56
  (_a = this.returnContainer.raws).push.apply(_a, rr);
57
57
  return OperatorRender_1.ExecuteState.EXECUTE;
@@ -35,7 +35,7 @@ var DrTargetAttr = /** @class */ (function (_super) {
35
35
  if (attrValue && attrName && (!this.elementSource.attrs.drForOf && !this.elementSource.attrs.drFor && !this.elementSource.attrs.drRepeat)) {
36
36
  var documentFragment = targetAttr.callBack(this.elementSource.element, attrValue, this.source.obj, this.rawSet);
37
37
  if (documentFragment) {
38
- var rr = RawSet_1.RawSet.checkPointCreates(documentFragment, this.source.config);
38
+ var rr = RawSet_1.RawSet.checkPointCreates(documentFragment, this.source.obj, this.source.config);
39
39
  (_d = this.elementSource.element.parentNode) === null || _d === void 0 ? void 0 : _d.replaceChild(documentFragment, this.elementSource.element);
40
40
  (_a = this.returnContainer.raws).push.apply(_a, rr);
41
41
  this.afterCallBack.onAttrInitCallBacks.push({
@@ -71,7 +71,7 @@ var DrTargetElement = /** @class */ (function (_super) {
71
71
  };
72
72
  }
73
73
  // fag.append(documentFragment)
74
- var rr = RawSet_1.RawSet.checkPointCreates(documentFragment, this.source.config);
74
+ var rr = RawSet_1.RawSet.checkPointCreates(documentFragment, this.source.obj, this.source.config);
75
75
  (_d = this.elementSource.element.parentNode) === null || _d === void 0 ? void 0 : _d.replaceChild(documentFragment, this.elementSource.element);
76
76
  (_a = this.returnContainer.raws).push.apply(_a, rr);
77
77
  this.afterCallBack.onElementInitCallBacks.push({
@@ -80,6 +80,7 @@ var DrTargetElement = /** @class */ (function (_super) {
80
80
  targetElement: targetElement,
81
81
  creatorMetaData: targetElement.__creatorMetaData
82
82
  });
83
+ // console.log(document.body.innerHTML);
83
84
  (_e = targetElement === null || targetElement === void 0 ? void 0 : targetElement.complete) === null || _e === void 0 ? void 0 : _e.call(targetElement, this.elementSource.element, this.source.obj, this.rawSet);
84
85
  }
85
86
  return OperatorRender_1.ExecuteState.EXECUTE;
@@ -43,7 +43,7 @@ var DrThis = /** @class */ (function (_super) {
43
43
  else {
44
44
  this.returnContainer.fag.append(RawSet_1.RawSet.drThisCreate(this.elementSource.element, this.elementSource.attrs.drThis, (_e = this.elementSource.attrs.drVarOption) !== null && _e !== void 0 ? _e : '', this.elementSource.attrs.drStripOption, this.source.obj, this.source.config));
45
45
  }
46
- var rr = RawSet_1.RawSet.checkPointCreates(this.returnContainer.fag, this.source.config);
46
+ var rr = RawSet_1.RawSet.checkPointCreates(this.returnContainer.fag, this.source.obj, this.source.config);
47
47
  (_f = this.elementSource.element.parentNode) === null || _f === void 0 ? void 0 : _f.replaceChild(this.returnContainer.fag, this.elementSource.element);
48
48
  (_a = this.returnContainer.raws).push.apply(_a, rr);
49
49
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dom-render",
3
- "version": "1.0.79",
3
+ "version": "1.0.82",
4
4
  "main": "DomRender.js",
5
5
  "license": "MIT",
6
6
  "description": "dom-render",
@@ -93,7 +93,7 @@ var Validator = /** @class */ (function () {
93
93
  target.value = this._value;
94
94
  }
95
95
  catch (e) {
96
- console.log('set value function is blocked ');
96
+ console.error('set value function is blocked ');
97
97
  }
98
98
  }
99
99
  if (this.getAutoValidAction()) {