Skip to content

Commit

Permalink
Commit 63 (Beta Candidate)
Browse files Browse the repository at this point in the history
MINOR BREAKING CHANGES
- Removed minor undocumented feature where custom tags
  could return false from init.
- When an observableArray changes, the property change
  notification for the length change is now before the
  array change notification. (For better behavior in some
  complex scenarios).

NEW FEATURES
- A new itemVar feature allows you to set a context variable
  on any tag, to provide access to the block context, even
  within nest tag blocks below.
  e.g. {{for people itemVar="~person"}}
  See BorisMoore/jsrender#256
  and http://jsfiddle.net/BorisMoore/zgr90L3s/

- New dom change notifications feature: A new domChange()
  method on data-linked tags will raise a "jsv-domchange"
  event on the parent element. {^{for}} and {^{if}} both
  use this method to raise a "jsv-domchange" event whenever
  they modify the DOM as a result of observable data changes.
  See http://jsfiddle.net/BorisMoore/vrw0kfxb/, and unit
  tests for "jsv-domchange".

- childTags("myFlowTag") can now be used to find instances
  of flow tags such as {{for}} and {{if}}, as well as
  custom (non-flow) tags. See unit tests,
  e.g. view.childTags(true, "if")

- Many new unit tests added for the above new features.

- Some small additional bug fixes.
  • Loading branch information
BorisMoore committed Mar 5, 2015
1 parent 074f8b2 commit 8700d57
Show file tree
Hide file tree
Showing 45 changed files with 854 additions and 365 deletions.
2 changes: 1 addition & 1 deletion demos/features/observability/computed-data-prototype.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<script src="../../resources/syntaxhighlighter.min.js" type="text/javascript"></script>
<link href="../../resources/demos.css" rel="stylesheet" type="text/css" />

<script src="http://code.jquery.com/jquery.js" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-1.11.2.js" type="text/javascript"></script>
<script src="../../../jsrender.js" type="text/javascript"></script>
<script src="../../../jquery.observable.js" type="text/javascript"></script>
<script src="../../../jquery.views.js" type="text/javascript"></script>
Expand Down
2 changes: 1 addition & 1 deletion demos/features/observability/computed-data.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<script src="../../resources/syntaxhighlighter.min.js" type="text/javascript"></script>
<link href="../../resources/demos.css" rel="stylesheet" type="text/css" />

<script src="http://code.jquery.com/jquery.js" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-1.11.2.js" type="text/javascript"></script>
<script src="../../../jsrender.js" type="text/javascript"></script>
<script src="../../../jquery.observable.js" type="text/javascript"></script>
<script src="../../../jquery.views.js" type="text/javascript"></script>
Expand Down
2 changes: 1 addition & 1 deletion demos/features/observability/computed-helper.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<script src="../../resources/syntaxhighlighter.min.js" type="text/javascript"></script>
<link href="../../resources/demos.css" rel="stylesheet" type="text/css" />

<script src="http://code.jquery.com/jquery.js" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-1.11.2.js" type="text/javascript"></script>
<script src="../../../jsrender.js" type="text/javascript"></script>
<script src="../../../jquery.observable.js" type="text/javascript"></script>
<script src="../../../jquery.views.js" type="text/javascript"></script>
Expand Down
2 changes: 1 addition & 1 deletion demos/features/observability/observing-paths.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<link href="../../resources/syntaxhighlighter.css" rel="stylesheet" type="text/css" />
<script src="../../resources/syntaxhighlighter.min.js" type="text/javascript"></script>
<link href="../../resources/demos.css" rel="stylesheet" type="text/css" />
<script src="http://code.jquery.com/jquery.js" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-1.11.2.js" type="text/javascript"></script>
<script src="../../../jsviews.js" type="text/javascript"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion demos/jQueryConfDemosOct2011/01_render-template.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<link href="../resources/syntaxhighlighter.css" rel="stylesheet" type="text/css" />
<script src="../resources/syntaxhighlighter.min.js" type="text/javascript"></script>

<script src="http://code.jquery.com/jquery.js" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-1.11.2.js" type="text/javascript"></script>
<script src="../../jsrender.js" type="text/javascript"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion demos/jQueryConfDemosOct2011/02_compiled-template.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<link href="../resources/syntaxhighlighter.css" rel="stylesheet" type="text/css" />
<script src="../resources/syntaxhighlighter.min.js" type="text/javascript"></script>

<script src="http://code.jquery.com/jquery.js" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-1.11.2.js" type="text/javascript"></script>
<script src="../../jsrender.js" type="text/javascript"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion demos/jQueryConfDemosOct2011/03_named-template.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<link href="../resources/syntaxhighlighter.css" rel="stylesheet" type="text/css" />
<script src="../resources/syntaxhighlighter.min.js" type="text/javascript"></script>

<script src="http://code.jquery.com/jquery.js" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-1.11.2.js" type="text/javascript"></script>
<script src="../../jsrender.js" type="text/javascript"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion demos/jQueryConfDemosOct2011/04_data-array.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<link href="../resources/syntaxhighlighter.css" rel="stylesheet" type="text/css" />
<script src="../resources/syntaxhighlighter.min.js" type="text/javascript"></script>

<script src="http://code.jquery.com/jquery.js" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-1.11.2.js" type="text/javascript"></script>
<script src="../../jsrender.js" type="text/javascript"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion demos/jQueryConfDemosOct2011/05_input.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<link href="../resources/syntaxhighlighter.css" rel="stylesheet" type="text/css" />
<script src="../resources/syntaxhighlighter.min.js" type="text/javascript"></script>

<script src="http://code.jquery.com/jquery.js" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-1.11.2.js" type="text/javascript"></script>
<script src="../../jsrender.js" type="text/javascript"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion demos/jQueryConfDemosOct2011/06_data-binding.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<link href="../resources/syntaxhighlighter.css" rel="stylesheet" type="text/css" />
<script src="../resources/syntaxhighlighter.min.js" type="text/javascript"></script>

<script src="http://code.jquery.com/jquery.js" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-1.11.2.js" type="text/javascript"></script>
<script src="../../jsrender.js" type="text/javascript"></script>
<script src="../../jquery.observable.js" type="text/javascript"></script>
<script src="../../jquery.views.js" type="text/javascript"></script>
Expand Down
2 changes: 1 addition & 1 deletion demos/jQueryConfDemosOct2011/06_data-binding2.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<link href="../resources/syntaxhighlighter.css" rel="stylesheet" type="text/css" />
<script src="../resources/syntaxhighlighter.min.js" type="text/javascript"></script>

<script src="http://code.jquery.com/jquery.js" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-1.11.2.js" type="text/javascript"></script>
<script src="../../jsrender.js" type="text/javascript"></script>
<script src="../../jquery.observable.js" type="text/javascript"></script>
<script src="../../jquery.views.js" type="text/javascript"></script>
Expand Down
2 changes: 1 addition & 1 deletion demos/jQueryConfDemosOct2011/07_observable.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<link href="../resources/syntaxhighlighter.css" rel="stylesheet" type="text/css" />
<script src="../resources/syntaxhighlighter.min.js" type="text/javascript"></script>

<script src="http://code.jquery.com/jquery.js" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-1.11.2.js" type="text/javascript"></script>
<script src="../../jsrender.js" type="text/javascript"></script>
<script src="../../jquery.observable.js" type="text/javascript"></script>
<script src="../../jquery.views.js" type="text/javascript"></script>
Expand Down
2 changes: 1 addition & 1 deletion demos/jQueryConfDemosOct2011/07_observable2.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<link href="../resources/syntaxhighlighter.css" rel="stylesheet" type="text/css" />
<script src="../resources/syntaxhighlighter.min.js" type="text/javascript"></script>

<script src="http://code.jquery.com/jquery.js" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-1.11.2.js" type="text/javascript"></script>
<script src="../../jsrender.js" type="text/javascript"></script>
<script src="../../jquery.observable.js" type="text/javascript"></script>
<script src="../../jquery.views.js" type="text/javascript"></script>
Expand Down
2 changes: 1 addition & 1 deletion demos/jQueryConfDemosOct2011/07_observable3.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<link href="../resources/syntaxhighlighter.css" rel="stylesheet" type="text/css" />
<script src="../resources/syntaxhighlighter.min.js" type="text/javascript"></script>

<script src="http://code.jquery.com/jquery.js" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-1.11.2.js" type="text/javascript"></script>
<script src="../../jsrender.js" type="text/javascript"></script>
<script src="../../jquery.observable.js" type="text/javascript"></script>
<script src="../../jquery.views.js" type="text/javascript"></script>
Expand Down
2 changes: 1 addition & 1 deletion demos/jQueryConfDemosOct2011/08_for-tag.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<link href="../resources/syntaxhighlighter.css" rel="stylesheet" type="text/css" />
<script src="../resources/syntaxhighlighter.min.js" type="text/javascript"></script>

<script src="http://code.jquery.com/jquery.js" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-1.11.2.js" type="text/javascript"></script>
<script src="../../jsrender.js" type="text/javascript"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion demos/jQueryConfDemosOct2011/09_for-composition.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<link href="../resources/syntaxhighlighter.css" rel="stylesheet" type="text/css" />
<script src="../resources/syntaxhighlighter.min.js" type="text/javascript"></script>

<script src="http://code.jquery.com/jquery.js" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-1.11.2.js" type="text/javascript"></script>
<script src="../../jsrender.js" type="text/javascript"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion demos/jQueryConfDemosOct2011/10_if-else-tag.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<link href="../resources/syntaxhighlighter.css" rel="stylesheet" type="text/css" />
<script src="../resources/syntaxhighlighter.min.js" type="text/javascript"></script>

<script src="http://code.jquery.com/jquery.js" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-1.11.2.js" type="text/javascript"></script>
<script src="../../jsrender.js" type="text/javascript"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion demos/jQueryConfDemosOct2011/11_editable-data.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<link href="../resources/demos.css" rel="stylesheet" type="text/css" />
<link href="../resources/masterdetail2.css" rel="stylesheet" type="text/css" />
<script src="http://code.jquery.com/jquery.js" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-1.11.2.js" type="text/javascript"></script>
<script src="../../jsrender.js" type="text/javascript"></script>
<script src="../../jquery.observable.js" type="text/javascript"></script>
<script src="../../jquery.views.js" type="text/javascript"></script>
Expand Down
2 changes: 1 addition & 1 deletion demos/jQueryConfDemosOct2011/12_helper-functions.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<link href="../resources/syntaxhighlighter.css" rel="stylesheet" type="text/css" />
<script src="../resources/syntaxhighlighter.min.js" type="text/javascript"></script>

<script src="http://code.jquery.com/jquery.js" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-1.11.2.js" type="text/javascript"></script>
<script src="../../jsrender.js" type="text/javascript"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion demos/jQueryConfDemosOct2011/13_converters.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<link href="../resources/syntaxhighlighter.css" rel="stylesheet" type="text/css" />
<script src="../resources/syntaxhighlighter.min.js" type="text/javascript"></script>

<script src="http://code.jquery.com/jquery.js" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-1.11.2.js" type="text/javascript"></script>
<script src="../../jsrender.js" type="text/javascript"></script>
<script src="../../jquery.observable.js" type="text/javascript"></script>
<script src="../../jquery.views.js" type="text/javascript"></script>
Expand Down
2 changes: 1 addition & 1 deletion demos/jQueryConfDemosOct2011/14_custom-tags.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<link href="../resources/syntaxhighlighter.css" rel="stylesheet" type="text/css" />
<script src="../resources/syntaxhighlighter.min.js" type="text/javascript"></script>

<script src="http://code.jquery.com/jquery.js" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-1.11.2.js" type="text/javascript"></script>
<script src="../../jsrender.js" type="text/javascript"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion demos/step-by-step/01_rendering-and-linking.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery.js" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-1.11.2.js" type="text/javascript"></script>
<script src="../../jsrender.js" type="text/javascript"></script>
<script src="../../jquery.observable.js" type="text/javascript"></script>
<script src="../../jquery.views.js" type="text/javascript"></script>
Expand Down
2 changes: 1 addition & 1 deletion demos/step-by-step/03_top-level-linking.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery.js" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-1.11.2.js" type="text/javascript"></script>
<script src="../../jsrender.js" type="text/javascript"></script>
<script src="../../jquery.observable.js" type="text/javascript"></script>
<script src="../../jquery.views.js" type="text/javascript"></script>
Expand Down
2 changes: 1 addition & 1 deletion demos/step-by-step/04_form-elements_if-binding.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery.js" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-1.11.2.js" type="text/javascript"></script>
<script src="../../jsrender.js" type="text/javascript"></script>
<script src="../../jquery.observable.js" type="text/javascript"></script>
<script src="../../jquery.views.js" type="text/javascript"></script>
Expand Down
2 changes: 1 addition & 1 deletion demos/step-by-step/06_accordion_switching-template.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery.js" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-1.11.2.js" type="text/javascript"></script>
<script src="../../jsrender.js" type="text/javascript"></script>
<script src="../../jquery.observable.js" type="text/javascript"></script>
<script src="../../jquery.views.js" type="text/javascript"></script>
Expand Down
2 changes: 1 addition & 1 deletion demos/step-by-step/10_todos.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<html>
<head>
<title>JsViews Demo: Todos</title>
<script src="http://code.jquery.com/jquery.js" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-1.11.2.js" type="text/javascript"></script>
<script src="../../jsrender.js" type="text/javascript"></script>
<script src="../../jquery.observable.js" type="text/javascript"></script>
<script src="../../jquery.views.js" type="text/javascript"></script>
Expand Down
18 changes: 10 additions & 8 deletions jquery.observable.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*! JsObservable v1.0.0-alpha: http://github.com/BorisMoore/jsviews and http://jsviews.com/jsviews
informal pre V1.0 commit counter: 62 (Beta Candidate) */
informal pre V1.0 commit counter: 63 (Beta Candidate) */
/*
* Subcomponent of JsViews
* Data change events for data-linking
Expand Down Expand Up @@ -29,7 +29,9 @@ informal pre V1.0 commit counter: 62 (Beta Candidate) */
},
$sub = $views.sub,
$eventSpecial = $.event.special,
slice = [].slice,
splice = [].splice,
concat = [].concat,
$isArray = $.isArray,
$expando = $.expando,
objectStr = "object",
Expand Down Expand Up @@ -308,10 +310,10 @@ informal pre V1.0 commit counter: 62 (Beta Candidate) */
var i, p, skip, parts, prop, path, dep, unobserve, callback, cbId, el, data, events, contextCb, items, cbBindings, depth, innerCb, parentObs,
allPath, filter, initNsArr, initNsArrLen,
ns = observeStr,
paths = this != 1? // Using != for IE<10 bug- see https://github.com/BorisMoore/jsviews/issues/237
[].concat.apply([], arguments) // Flatten the arguments - this is a 'recursive call' with params using the 'wrapped array'
paths = this != 1 // Using != for IE<10 bug- see https://github.com/BorisMoore/jsviews/issues/237
? concat.apply([], arguments) // Flatten the arguments - this is a 'recursive call' with params using the 'wrapped array'
// style - such as innerObserve([object], path.path, [origRoot], path.prm, innerCb, ...);
: Array.apply(0, arguments), // Don't flatten - this is the first 'top-level call, to innerObserve.apply(1, paths)
: slice.call(arguments), // Don't flatten - this is the first 'top-level call, to innerObserve.apply(1, paths)
lastArg = paths.pop() || false,
root = paths.shift(),
object = root,
Expand Down Expand Up @@ -492,7 +494,7 @@ informal pre V1.0 commit counter: 62 (Beta Candidate) */
allowArray = this != false, // If this === false, this is a call from observeAndBind - doing binding of datalink expressions. We don't bind
// 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 != false, rather than this !== false because of IE<10 bug- see https://github.com/BorisMoore/jsviews/issues/237
paths = Array.apply(0, arguments),
paths = slice.call(arguments),
origRoot = paths[0];

if (origRoot + "" === origRoot && allowArray) {
Expand All @@ -511,7 +513,7 @@ informal pre V1.0 commit counter: 62 (Beta Candidate) */

function observe_apply() {
// $.observe(), but allowing you to include arrays within the arguments - which you want flattened.
var args = [].concat.apply([], arguments); // Flatten the arguments
var args = concat.apply([], arguments); // Flatten the arguments
return $observe.apply(args.shift(), args);
}

Expand Down Expand Up @@ -794,7 +796,7 @@ informal pre V1.0 commit counter: 62 (Beta Candidate) */
var _data = this._data,
oldLength = _data.length;
_data.splice(oldIndex, numToMove);
_data.splice.apply(_data, [newIndex, 0].concat(items));
splice.apply(_data, [newIndex, 0].concat(items));
this._trigger({change: "move", oldIndex: oldIndex, index: newIndex, items: items}, oldLength);
},

Expand All @@ -817,10 +819,10 @@ informal pre V1.0 commit counter: 62 (Beta Candidate) */
length = _data.length,
$data = $([_data]);

$data.triggerHandler(arrayChangeStr, eventArgs);
if (length !== oldLength) {
$data.triggerHandler(propertyChangeStr, {change: "set", path: "length", value: length, oldValue: oldLength});
}
$data.triggerHandler(arrayChangeStr, eventArgs);
}
};

Expand Down
Loading

0 comments on commit 8700d57

Please sign in to comment.