Skip to content

Commit 0bc2d7c

Browse files
committed
v2.0
1 parent 2fc31e8 commit 0bc2d7c

5 files changed

Lines changed: 257 additions & 252 deletions

File tree

browser.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,9 @@
190190
if (CreateLink) {
191191

192192
element.wsLink = WsUser.CreateLink(path, element);
193-
element.datacontext = element.wsLink.datacontext;
193+
element.wsLink.bindAllElements = function (elem) { bindAllElements(elem, rebinding); };
194194
element.setAttribute("linked", path);
195195
element.removeAttribute("link");
196-
bindAllElements(element, rebinding);
197196
}
198197
}
199198

@@ -470,15 +469,14 @@
470469

471470
element: { value: d.rootElement, writable: false, configurable: false, enumerable: false },
472471

473-
source: { value: d.source, writable: false, configurable: false, enumerable: false },
474-
//source: {
475-
// configurable: false, enumerable: false,
472+
source: {
473+
configurable: false, enumerable: false,
476474

477-
// get: function () {
475+
get: function () {
478476

479-
// return d.arrPath.reduce(function (s, k) { return s[k]; }, d.rootSource);
480-
// }
481-
//},
477+
return d.arrPath.reduce(function (s, k) { return s[k]; }, d.rootSource);
478+
}
479+
},
482480

483481
property: { value: d.property || "-change", writable: false, configurable: false, enumerable: false },
484482

@@ -541,7 +539,7 @@
541539

542540
if (d.rootSource?._events && (
543541
!d.rootSource._events["-"] ||
544-
!d.rootSource._events["-"].find(function (fn) { return fn.name.includes("_bindHandler"); })
542+
!d.rootSource._events["-"].find(function (fn) { return fn.name.includes("bindHandler"); })
545543
)) {
546544

547545
d.rootSource.on("-", bindHandler.bind(d.rootElement), d.rootElement);

datacontext.js

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -446,26 +446,24 @@
446446

447447
var ret = Reflect.set(target, property, newValue, proxy);
448448

449-
var isDC = newValue && newValue._isDataContext;
450-
var isNew = isDC && newValue._parent !== proxy && oldValue === undefined;
449+
var isDC = newValue?._isDataContext;
450+
var isNew = oldValue === undefined;
451+
451452
if (isDC) {
452453
newValue._isModified = true;
453454
newValue._parent = proxy;
454-
}
455-
456-
if (isDC && newValue._propertyName !== property) {
457-
458-
//console.log("'-reposition' set: newValue propertyName is change ", newValue + "", ">", property, event);
459-
eventName = "reposition";
460455
newValue._propertyName = property;
461456
}
462-
else if (isDC && isNew) {
463457

458+
if (isNew) {
464459
//console.log("'-new' set: oldValue is undefined", property, event);
465460
eventName = "new";
466461
}
462+
else if (isDC && typeof newValue._propertyName === 'string' && newValue._propertyName !== property) {
463+
//console.log("'-reposition' set: newValue propertyName is change ", newValue + "", ">", property, event);
464+
eventName = "reposition";
465+
}
467466
else {
468-
469467
//console.log("'-set' set: newValue parent is change", property, event);
470468
eventName = "set";
471469
}
@@ -678,6 +676,7 @@
678676

679677
if (!def._isDataContext) { def = createDataContext(def); }
680678
if (val?._events) { def._events = val._events; }
679+
if (val?._propertyName && val._parent) { val._parent[val._propertyName] = def; }
681680

682681
it.next();
683682
it.next();
@@ -686,6 +685,14 @@
686685
}
687686
else if (_typeof(val) !== _typeof(def)) {
688687

688+
if (val?._isDataContext) {
689+
690+
def = createDataContext(def);
691+
def._events = val._events;
692+
693+
if (val?._propertyName && val._parent) { val._parent[val._propertyName] = def; }
694+
}
695+
689696
return def;
690697
}
691698

0 commit comments

Comments
 (0)