You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
BREAKING CHANGES:
- tag.update() method renamed to tag.updateValue() (for consistency
with tag.setValue() and new tag.updateValues() and tag.setValues()
APIs - see below)
- $.views.getCtx(tagCtx.ctx.foo) API introduced in commit 80 has been
removed. Use view.ctxPrm("foo") instead.
Feature improvements:
Many new and improved features, particularly related to custom tag
scenarios, as shown below. Documentation to follow on each of these
improvemnts to provide more information and specifics...
- Contextual parameters now support 2-way data-binding:
<input data-link="~foo" />
- New APIs view.ctxPrm() and tag.ctxPrm():
Programmatically get/set contextual parameters:
var fooValue = view.ctxPrm("foo"); // Get value of ~foo
view.ctxPrm("foo", newValue); // Set (update observably) value of ~foo
Similarly:
var fooValue = tag.ctxPrm("foo"); // Get value of ~foo
tag.ctxPrm("foo", newValue); // Set value of ~foo
- tagCtx now has a tagCtx.contentView property, which is a view object
wrapping the contents of the tag (or of the {{else}} block for the
tag) - whether content rendered by the tag (using a tag render() method
or template), or block content wrapped by the tag.
- The APIS:
tagCtx.contents()
tagCtx.nodes() and
tagCtx.childTags()
all return contents of the block - and are equivalent to:
tagCtx.contentView.contents() etc.
(And similarly for the APIs tag.contents(), tag.nodes() and
tag.childTags()...)
- Improvements to APIs:
tag.cvtArgs(), tagCtx.cvtArgs(), tag.bndArgs(), tagCtx.bndArgs()
- Views have a new property: view.root, which provides access to the "root
ancestor view" (the uppermost view under the top view).
- Improvements to APIs:
tag.setValue(), tag.setValues(), tag.updateValue(), tag.updateValues()
and tagCtx.setValues(). (Details and documentation to follow).
- Improvements to linkedElems APIS: linkedElems are now supported on tags
with one or more {{else}} blocks. Each {{else} block can have its own
linkedElem bindings.
- New support for <input type="number"/>
Bug fixes:
- #380
Support for <input type="number"/>
- #382
Cannot set property '_prv' of undefined
- Several minor bug fixes
Unit tests:
- Several additional unit tests
// Uses the contextCb callback to execute the compiled exprOb template in the context of the view/data etc. to get the returned value, typically an object or array.
416
420
// If it is an array, registers array binding
417
421
varorigRt=root;
418
-
// Note: For jsviews/issues/292 ctxCb will need var ctxCb = contextCb || function(exprOb, origRt) {return exprOb._jsv(origRt);};
422
+
// Note: For jsviews/issues/292 ctxCb will need var ctxCb = contextCb || function(exprOb, origRt) {return exprOb._cpfn(origRt);};
paths=this!=1// Using != for IE<10 bug- see jsviews/issues/237
476
479
? concat.apply([],arguments)// Flatten the arguments - this is a 'recursive call' with params using the 'wrapped array'
@@ -481,6 +484,7 @@ if (!$.observe) {
481
484
object=root,
482
485
l=paths.length;
483
486
487
+
origRoots.unshift(root);
484
488
if(lastArg+""===lastArg){// If last arg is a string then this observe call is part of an observeAll call,
485
489
allPath=lastArg;// and the last three args are the parentObs array, the filter, and the allPath string.
486
490
parentObs=paths.pop();
@@ -505,6 +509,7 @@ if (!$.observe) {
505
509
}
506
510
507
511
if(unobserve&&callback&&!callback._cId){
512
+
origRoots.shift();
508
513
return;
509
514
}
510
515
@@ -548,18 +553,13 @@ if (!$.observe) {
548
553
depth=0;
549
554
for(i=0;i<l;i++){
550
555
path=paths[i];
551
-
if(path===""){
556
+
if(path===""||path===root){
552
557
continue;
553
558
}
554
559
if(path&&path._ar){
555
560
allowArray+=path._ar;// Switch on allowArray for depends paths, and off, afterwards.
556
561
continue;
557
562
}
558
-
if(path&&path._cp){// Contextual parameter
559
-
contextCb=$sub._gccb(path[0]);// getContextCb: Get context callback for the contextual view (where contextual param evaluated/assigned)
560
-
origRoot=root=path[0].data;// Contextual data
561
-
path=path[1];
562
-
}
563
563
object=root;
564
564
if(""+path===path){
565
565
// Consider support for computed paths: jsviews/issues/292
@@ -580,20 +580,24 @@ if (!$.observe) {
580
580
}
581
581
if(contextCb){
582
582
items=contextCb(path,root,depth);
583
-
contextCb=innerContextCb;
584
-
}
585
-
if(items){
586
-
// If the array of objects and paths returned by contextCb is non empty, insert them
587
-
// into the sequence, replacing the current item (path). Otherwise simply remove current item (path)
588
-
l+=items.length-1;
589
-
splice.apply(paths,[i--,1].concat(items));
590
-
continue;
591
583
}
584
+
contextCb=innerContextCb;
592
585
parts=path.split(".");
586
+
}elseif(path&&path._cxp){// contextual parameter
587
+
view=path.shift();// Contextual data
588
+
if(_ocpinview){
589
+
root=view;
590
+
contextCb=0;
591
+
}else{
592
+
contextCb=$sub._gccb(view);// getContextCb: Get context callback for the contextual view (where contextual param evaluated/assigned)
593
+
root=view.data;
594
+
}
595
+
items=path;
596
+
items.push(origRoot);
593
597
}else{
594
598
if(!$isFunction(path)){
595
-
if(path&&path._jsv){
596
-
// This is a compiled function for binding to an object returned by a helper/data function.
599
+
if(path&&path._cpfn){
600
+
// Path is an exprOb returned by a computed property - helper/data function (compiled expr function).
597
601
// Set current object on exprOb.ob, and get innerCb for updating the object
598
602
innerCb=unobserve ? path.cb : getInnerCb(path);
599
603
// innerCb._ctx = callback._ctx; Could pass context (e.g. linkCtx) for use in a depends = function() {} call, so depends is different for different linkCtx's
// Case of property setter/getter - with convention that property is getter and property.set is setter
807
-
leaf=leaf._wrp// Case of JsViews 2-way data-linking to a helper function as getter, with a setter.
827
+
leaf=leaf._vw// Case of JsViews 2-way data-linking to an observable context parameter, with a setter.
808
828
// The view will be the this pointer for getter and setter. Note: this is the one scenario where path is "".
809
-
||leaf;
829
+
||leaf;
810
830
getter=property;
811
831
setter=getter.set===true ? getter : getter.set;
812
832
property=getter.call(leaf);// get - only treated as getter if also a setter. Otherwise it is simply a property of type function. See unit tests 'Can observe properties of type function'.
0 commit comments