Skip to content

Commit

Permalink
v1.0.12 release
Browse files Browse the repository at this point in the history
This update contains a performance improvement, suggested in the issue:
#453

All instances of code which test whether an object, someObject, is
of type string by testing:
    if (someObject + "" !== someObject) {...}
have been replaced by more performant code:
    if (typeof someObject !== 'string') {...}

This change applies to jsrender, jsviews and jsobservable files...

Sync with other changes in v1.0.12 for JsViews
  • Loading branch information
BorisMoore committed Nov 12, 2022
1 parent 43c4710 commit 91ea2c9
Show file tree
Hide file tree
Showing 69 changed files with 637 additions and 604 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## JsViews: next-generation MVVM and MVP framework - bringing templates to life

[![CDNJS version](https://img.shields.io/cdnjs/v/jsviews.svg)](https://cdnjs.com/libraries/jsviews)

*The power of MVVM, the flexibility of JavaScript, the speed and ease of JsRender templates and jQuery*<br/>

**JsViews** builds on top of **[JsRender](http://www.jsviews.com/#jsrender)** templates, and adds data-binding and **[observable data](http://www.jsviews.com/#jsobservable)**, to provide a fully-fledged MVVM platform for easily creating interactive data-driven single-page apps and websites.
Expand Down
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="//code.jquery.com/jquery-3.5.1.js" type="text/javascript"></script>
<script src="//code.jquery.com/jquery-3.6.1.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="//code.jquery.com/jquery-3.5.1.js" type="text/javascript"></script>
<script src="//code.jquery.com/jquery-3.6.1.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="//code.jquery.com/jquery-3.5.1.js" type="text/javascript"></script>
<script src="//code.jquery.com/jquery-3.6.1.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="//code.jquery.com/jquery-3.5.1.js" type="text/javascript"></script>
<script src="//code.jquery.com/jquery-3.6.1.js" type="text/javascript"></script>
<script src="../../../jsviews.js" type="text/javascript"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion demos/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ <h3>Demos</h3>

<div class="box">
<div class="desc">JsRender templates are optimized for high-performance pure string-based rendering, without DOM or jQuery dependency</div>
<div class="subhead"><b><a href="http://borismoore.github.com/jsrender/demos/index.html">JsRender: Demos</a></b></div>
<div class="subhead"><b><a href="http://borismoore.github.io/jsrender/demos/index.html">JsRender: Demos</a></b></div>
</div>

<div class="subhead">Other links:</div>
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="//code.jquery.com/jquery-3.5.1.js" type="text/javascript"></script>
<script src="//code.jquery.com/jquery-3.6.1.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="//code.jquery.com/jquery-3.5.1.js" type="text/javascript"></script>
<script src="//code.jquery.com/jquery-3.6.1.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="//code.jquery.com/jquery-3.5.1.js" type="text/javascript"></script>
<script src="//code.jquery.com/jquery-3.6.1.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="//code.jquery.com/jquery-3.5.1.js" type="text/javascript"></script>
<script src="//code.jquery.com/jquery-3.6.1.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="//code.jquery.com/jquery-3.5.1.js" type="text/javascript"></script>
<script src="//code.jquery.com/jquery-3.6.1.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="//code.jquery.com/jquery-3.5.1.js" type="text/javascript"></script>
<script src="//code.jquery.com/jquery-3.6.1.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="//code.jquery.com/jquery-3.5.1.js" type="text/javascript"></script>
<script src="//code.jquery.com/jquery-3.6.1.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="//code.jquery.com/jquery-3.5.1.js" type="text/javascript"></script>
<script src="//code.jquery.com/jquery-3.6.1.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="//code.jquery.com/jquery-3.5.1.js" type="text/javascript"></script>
<script src="//code.jquery.com/jquery-3.6.1.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="//code.jquery.com/jquery-3.5.1.js" type="text/javascript"></script>
<script src="//code.jquery.com/jquery-3.6.1.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="//code.jquery.com/jquery-3.5.1.js" type="text/javascript"></script>
<script src="//code.jquery.com/jquery-3.6.1.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="//code.jquery.com/jquery-3.5.1.js" type="text/javascript"></script>
<script src="//code.jquery.com/jquery-3.6.1.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="//code.jquery.com/jquery-3.5.1.js" type="text/javascript"></script>
<script src="//code.jquery.com/jquery-3.6.1.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="//code.jquery.com/jquery-3.5.1.js" type="text/javascript"></script>
<script src="//code.jquery.com/jquery-3.6.1.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="//code.jquery.com/jquery-3.5.1.js" type="text/javascript"></script>
<script src="//code.jquery.com/jquery-3.6.1.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="//code.jquery.com/jquery-3.5.1.js" type="text/javascript"></script>
<script src="//code.jquery.com/jquery-3.6.1.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="//code.jquery.com/jquery-3.5.1.js" type="text/javascript"></script>
<script src="//code.jquery.com/jquery-3.6.1.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="//code.jquery.com/jquery-3.5.1.js" type="text/javascript"></script>
<script src="//code.jquery.com/jquery-3.6.1.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="//code.jquery.com/jquery-3.5.1.js" type="text/javascript"></script>
<script src="//code.jquery.com/jquery-3.6.1.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="//code.jquery.com/jquery-3.5.1.js" type="text/javascript"></script>
<script src="//code.jquery.com/jquery-3.6.1.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="//code.jquery.com/jquery-3.5.1.js" type="text/javascript"></script>
<script src="//code.jquery.com/jquery-3.6.1.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="//code.jquery.com/jquery-3.5.1.js" type="text/javascript"></script>
<script src="//code.jquery.com/jquery-3.6.1.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
25 changes: 13 additions & 12 deletions jquery.observable.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! JsObservable v1.0.11: http://jsviews.com/#jsobservable */
/*! JsObservable v1.0.12: http://jsviews.com/#jsobservable */
/*
* Subcomponent of JsViews
* Data change events for data-linking
Expand Down Expand Up @@ -44,7 +44,7 @@ if (!$ || !$.fn) {
throw "jquery.observable.js requires jQuery"; // We require jQuery
}

var versionNumber = "v1.0.11",
var versionNumber = "v1.0.12",
_ocp = "_ocp", // Observable contextual parameter
$observe, $observable,

Expand Down Expand Up @@ -75,6 +75,7 @@ var versionNumber = "v1.0.11",
$isFunction = $.isFunction,
$expando = $.expando,
$isArray = $.isArray,
STRING = "string",
OBJECT = "object";

if ($views.jsviews !== versionNumber) {
Expand Down Expand Up @@ -149,7 +150,7 @@ if (!$.observe) {
: 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) {
} else if (typeof path !== STRING) {
root = nextObj = path = (path === undefined ? null : path);
if (nextObj !== object) {
out.push(object = nextObj);
Expand Down Expand Up @@ -521,7 +522,7 @@ if (!$.observe) {
}

while ((prop = prts.shift()) !== undefined) {
if (obj && typeof obj === OBJECT && "" + prop === prop) {
if (obj && typeof obj === OBJECT && typeof prop === STRING) {
if (prop === "") {
continue;
}
Expand Down Expand Up @@ -670,7 +671,7 @@ if (!$.observe) {
allowArray += path._ar; // Switch on allowArray for depends paths, and off, afterwards.
continue;
}
if ("" + path === path) {
if (typeof path === STRING) {
parts = path.split("^");
if (parts[1]) {
// We bind the leaf, plus additional nodes based on depth.
Expand All @@ -693,7 +694,7 @@ if (!$.observe) {
continue;
}
}
if (pth + "" === pth) {
if (typeof pth === STRING) {
observePath(ob, pth.split("."));
} else {
observeObjectPaths(items.shift(), items, callback, contextCb);
Expand Down Expand Up @@ -732,7 +733,7 @@ if (!$.observe) {
l = paths.length;
while (l--) { // Step backwards through paths and objects
pth = paths[l];
if (pth + "" === pth || pth && (pth._ar || pth._cpfn)) {
if (typeof pth === STRING || pth && (pth._ar || pth._cpfn)) {
pths.unshift(pth); // This is a path so add to arr
} else { // This is an object
observeObjectPaths(pth, pths, callback, contextCb);
Expand All @@ -751,7 +752,7 @@ if (!$.observe) {
lastArg = paths.pop() || false,
m = paths.length;

if (lastArg + "" === lastArg) { // If last arg is a string then this observe call is part of an observeAll call,
if (typeof lastArg === STRING) { // 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();
filter = paths.pop();
Expand All @@ -761,7 +762,7 @@ if (!$.observe) {
if (lastArg === !!lastArg) {
unobserve = lastArg;
lastArg = paths[m-1];
lastArg = m && lastArg + "" !== lastArg && (!lastArg || $isFunction(lastArg)) ? (m--, paths.pop()) : undefined;
lastArg = m && typeof lastArg !== STRING && (!lastArg || $isFunction(lastArg)) ? (m--, paths.pop()) : undefined;
if (unobserve && !m && $isFunction(paths[0])) {
lastArg = paths.shift();
}
Expand Down Expand Up @@ -821,7 +822,7 @@ if (!$.observe) {
paths = slice.call(arguments),
pth = paths[0];

if (pth + "" === pth) {
if (typeof pth === STRING) {
initialNs = pth; // The first arg is a namespace, since it is a string
paths.shift();
}
Expand All @@ -839,7 +840,7 @@ if (!$.observe) {
};

$observable = function(ns, data, delay) {
if (ns + "" !== ns) {
if (typeof ns !== STRING) {
delay = data;
data = ns;
ns = "";
Expand Down Expand Up @@ -900,7 +901,7 @@ if (!$.observe) {
setProperty: function(path, value, nonStrict, isCpfn) {
path = path || "";
var key, pair, parts, tempBatch,
multi = path + "" !== path, // Hash of paths
multi = typeof path !== STRING, // Hash of paths
self = this,
object = self._data,
batch = self._batch;
Expand Down
Loading

0 comments on commit 91ea2c9

Please sign in to comment.