Skip to content

Commit

Permalink
Commit 90 (v0.9.90 - Beta)
Browse files Browse the repository at this point in the history
Minor bug fixes:

- Tags and converters with 'depends' as a function: the function now
  receives the tag as 'this' pointer and the contextual data object as
  parameter

- Fix for syntax error bug for debugMode(true) with {{else}} blocks
  https://stackoverflow.com/questions/47065521/migrating-jsrender-to-jsviews-else-issue
  #395

- Fix for bug in advanced nested $.render() call scenarios (when
  useViews advanced setting is false):
  BorisMoore/jsrender#333

- linkedCtxParam bugs:
  - If linkedCtxParam="foo", and onUpdate is not false, two-way binding
    on ~foo continues to work correctly after an update
  - If linkedCtxParam="foo", 2 way binding now works correctly
    for properties of ~foo (~foo.bar...)

- Fix for validation bug for 'preventInvalidData'. Now uses
  onBeforeUpdateValue rather than onBeforeChange

Feature improvements and changes for custom tags:

- Very minor breaking changes:
  - The (undocumented) onBeforeBind event has been removed
  - Signature change for tag.cvtArgs(): does not accept a converter
    parameter

- 'lateRender' is now available as a tag option (overridden by inline
  lateRender=false)

- 'trigger' is now available as a tag option (overridden by inline
 trigger=...)

- 'linkedElement' and 'linkedCtxParam' can now be set in init()

- Calling tag.updateValue() now updates both external bindings and internal
  content dependencies (which it updates by calling tag.setValue()...)

- If a tag has no args, and argDefault is not set to false, then the
  tagCtx.args[] will be [#data] (where #data is the current data
   context). Note that the render() method will receive the current data
   as parameter. (See https://www.jsviews.com/#tagsapi@argdefault)

Unit tests:

- Several additional unit tests

Documentation:

- JsViews custom tag controls topic has been augmented. (More content to
  be added in next updates) See: http://www.jsviews.com/#jsvtagcontrols
  • Loading branch information
BorisMoore committed Nov 29, 2017
1 parent 5e052dd commit df35f6e
Show file tree
Hide file tree
Showing 29 changed files with 4,919 additions and 6,812 deletions.
24 changes: 10 additions & 14 deletions jquery.observable.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! JsObservable v0.9.89 (Beta): http://jsviews.com/#jsobservable */
/*! JsObservable v0.9.90 (Beta): http://jsviews.com/#jsobservable */
/*
* Subcomponent of JsViews
* Data change events for data-linking
Expand Down Expand Up @@ -44,7 +44,7 @@ if (!$ || !$.fn) {
throw "JsObservable requires jQuery"; // We require jQuery
}

var versionNumber = "v0.9.89",
var versionNumber = "v0.9.90",
_ocp = "_ocp", // Observable contextual parameter
$observe, $observable,

Expand Down Expand Up @@ -136,11 +136,11 @@ if (!$.observe) {

for (i = 0; i < l; i++) {
path = paths[i];
if ($isFunction(path)) {
rt = root._ocp
? root.view.data // observable contextual parameter
: root;
out = out.concat(dependsPaths(path.call(rt, rt, callback), root, callback));
if ($isFunction(path)) { // path is a depends function, returning [path1, ...]
rt = root.tagName
? root.linkCtx.data // root is tag instance. rt is current data context of tag
: root; // rt = root = current data context of computed prop
out = out.concat(dependsPaths(path.call(root, rt, callback), rt, callback));
continue;
} else if ("" + path !== path) {
root = nextObj = path;
Expand Down Expand Up @@ -451,7 +451,7 @@ if (!$.observe) {

function bindArray(arr, unbind, isArray, relPath) {
if (allowArray) {
// allowArray is 1 if this is a call to observe that does not come from observeAndBind (tag binding), or is from a `depends` path,
// allowArray is 1 if this is a call to observe that does not come from observeAndBind (tag binding), or is from a 'depends' path,
// so we allow arrayChange binding. Otherwise allowArray is zero.
var prevObj = object,
prevAllPath = allPath;
Expand Down Expand Up @@ -484,7 +484,6 @@ if (!$.observe) {
object = root,
l = paths.length;

origRoots.unshift(root);
if (lastArg + "" === lastArg) { // If last arg is a string then this observe call is part of an observeAll call,
allPath = lastArg; // and the last three args are the parentObs array, the filter, and the allPath string.
parentObs = paths.pop();
Expand All @@ -509,7 +508,6 @@ if (!$.observe) {
}

if (unobserve && callback && !callback._cId) {
origRoots.shift();
return;
}

Expand Down Expand Up @@ -703,7 +701,7 @@ if (!$.observe) {
if (dep = prop.depends) {
// This is a computed observable. We will observe any declared dependencies.
// Pass {_ar: ...} objects to switch on allowArray, for depends paths, then return to contextual allowArray value
innerObserve([object._ocp ? object.view.data : object], dependsPaths(dep, object, callback), callback, contextCb, unobserve);
innerObserve([object], dependsPaths(dep, object, callback), callback, contextCb, unobserve);
}
break;
}
Expand All @@ -717,7 +715,6 @@ if (!$.observe) {
}

// Return the cbBindings to the top-level caller, along with the cbId
origRoots.shift();
return {cbId: cbId, bnd: cbBindings, s: cbBindingsStore};
}

Expand All @@ -726,8 +723,7 @@ if (!$.observe) {
// arrayChange events in this scenario. Instead, {^{for}} and similar do specific arrayChange binding to the tagCtx.args[0] value, in onAfterLink.
// Note deliberately using this == 1, rather than this === 1 because of IE<10 bug- see jsviews/issues/237
paths = slice.call(arguments),
origRoot = paths[0],
origRoots = [origRoot];
origRoot = paths[0];

if (origRoot + "" === origRoot && allowArray) {
initialNs = origRoot; // The first arg is a namespace, since it is a string, and this call is not from observeAndBind
Expand Down
4 changes: 2 additions & 2 deletions jquery.observable.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion jquery.observable.min.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit df35f6e

Please sign in to comment.