Skip to content

Commit

Permalink
v1.0.11 release
Browse files Browse the repository at this point in the history
Minor bug fix:
See #452
  html comments not working in tables
  • Loading branch information
BorisMoore committed Jan 28, 2021
1 parent 0eb921e commit 43c4710
Show file tree
Hide file tree
Showing 40 changed files with 416 additions and 268 deletions.
4 changes: 2 additions & 2 deletions jquery.observable.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! JsObservable v1.0.10: http://jsviews.com/#jsobservable */
/*! JsObservable v1.0.11: 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.10",
var versionNumber = "v1.0.11",
_ocp = "_ocp", // Observable contextual parameter
$observe, $observable,

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.

10 changes: 4 additions & 6 deletions jquery.views.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! jquery.views.js v1.0.10: http://jsviews.com/ */
/*! jquery.views.js v1.0.11: http://jsviews.com/ */
/*
* Interactive data-driven views using JsRender templates.
* Subcomponent of JsViews
Expand Down Expand Up @@ -44,7 +44,7 @@ var setGlobals = $ === false; // Only set globals if script block in browser (no
jsr = jsr || setGlobals && global.jsrender;
$ = $ || global.jQuery;

var versionNumber = "v1.0.10",
var versionNumber = "v1.0.11",
requiresStr = "jquery.views.js requires ";

if (!$ || !$.fn) {
Expand Down Expand Up @@ -1286,15 +1286,13 @@ function viewLink(outerData, parentNode, prevNode, nextNode, html, refresh, cont
if (deferChar === "+") {
if (deferPath.charAt(j) === "-") {
j--;
targetParent = targetParent.previousSibling;
targetParent = targetParent.previousElementSibling; // IE9 or later only
} else {
targetParent = targetParent.parentNode;
}
} else {
targetParent = targetParent.lastChild;
targetParent = targetParent.lastElementChild; // IE9 or later only
}
// Note: Can use previousSibling and lastChild, not previousElementSibling and lastElementChild,
// since we have removed white space within elCnt. Hence support IE < 9
}
}
if (bindChar === "^") {
Expand Down
6 changes: 3 additions & 3 deletions jquery.views.min.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions jsrender.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! JsRender v1.0.10: http://jsviews.com/#jsrender */
/*! JsRender v1.0.11: http://jsviews.com/#jsrender */
/*! **VERSION FOR WEB** (For NODE.JS see http://jsviews.com/download/jsrender-node.js) */
/*
* Best-of-breed templating in browser or on Node.js.
Expand Down Expand Up @@ -44,7 +44,7 @@ var setGlobals = $ === false; // Only set globals if script block in browser (no

$ = $ && $.fn ? $ : global.jQuery; // $ is jQuery passed in by CommonJS loader (Browserify), or global jQuery.

var versionNumber = "v1.0.10",
var versionNumber = "v1.0.11",
jsvStoreName, rTag, rTmplString, topView, $views, $expando,
_ocp = "_ocp", // Observable contextual parameter

Expand Down Expand Up @@ -753,7 +753,7 @@ function renderTag(tagName, parentView, tmpl, tagCtxs, isUpdate, onError) {
tag.linkCtx = linkCtx;
if (tag._.bnd = boundTag || linkCtx.fn) {
// Bound if {^{tag...}} or data-link="{tag...}"
tag._.ths = tagCtx.params.props.this; // Tag has a this=expr binding, to get javascript reference to tag instance
tag._.ths = tagCtx.params.props["this"]; // Tag has a this=expr binding, to get javascript reference to tag instance
tag._.lt = tagCtxs.lt; // If a late path @some.path has not returned @some object, mark tag as late
tag._.arrVws = {};
} else if (tag.dataBoundOnly) {
Expand Down Expand Up @@ -1115,6 +1115,8 @@ function compileTmpl(name, tmpl, parentTmpl, options) {
// Look for server-generated script block with id "./some/file.html"
elem = document.getElementById(value);
}
} else if (value.charAt(0) === "#") {
elem = document.getElementById(value.slice(1));
} else if ($.fn && !$sub.rTmpl.test(value)) {
try {
elem = $(value, document)[0]; // if jQuery is loaded, test for selector returning elements, and get first element
Expand Down
4 changes: 2 additions & 2 deletions jsrender.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion jsrender.min.js.map

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions jsviews.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! jsviews.js v1.0.10 single-file version: http://jsviews.com/ */
/*! jsviews.js v1.0.11 single-file version: http://jsviews.com/ */
/*! includes JsRender, JsObservable and JsViews - see: http://jsviews.com/#download */

/* Interactive data-driven views using JsRender templates */
Expand Down Expand Up @@ -47,7 +47,7 @@ if (!$ || !$.fn) {
throw "JsViews requires jQuery"; // We require jQuery
}

var versionNumber = "v1.0.10",
var versionNumber = "v1.0.11",

jsvStoreName, rTag, rTmplString, topView, $views, $observe, $observable, $expando,
_ocp = "_ocp", // Observable contextual parameter
Expand Down Expand Up @@ -757,7 +757,7 @@ function renderTag(tagName, parentView, tmpl, tagCtxs, isUpdate, onError) {
tag.linkCtx = linkCtx;
if (tag._.bnd = boundTag || linkCtx.fn) {
// Bound if {^{tag...}} or data-link="{tag...}"
tag._.ths = tagCtx.params.props.this; // Tag has a this=expr binding, to get javascript reference to tag instance
tag._.ths = tagCtx.params.props["this"]; // Tag has a this=expr binding, to get javascript reference to tag instance
tag._.lt = tagCtxs.lt; // If a late path @some.path has not returned @some object, mark tag as late
tag._.arrVws = {};
} else if (tag.dataBoundOnly) {
Expand Down Expand Up @@ -1119,6 +1119,8 @@ function compileTmpl(name, tmpl, parentTmpl, options) {
// Look for server-generated script block with id "./some/file.html"
elem = document.getElementById(value);
}
} else if (value.charAt(0) === "#") {
elem = document.getElementById(value.slice(1));
} else if ($.fn && !$sub.rTmpl.test(value)) {
try {
elem = $(value, document)[0]; // if jQuery is loaded, test for selector returning elements, and get first element
Expand Down Expand Up @@ -5514,15 +5516,13 @@ function viewLink(outerData, parentNode, prevNode, nextNode, html, refresh, cont
if (deferChar === "+") {
if (deferPath.charAt(j) === "-") {
j--;
targetParent = targetParent.previousSibling;
targetParent = targetParent.previousElementSibling; // IE9 or later only
} else {
targetParent = targetParent.parentNode;
}
} else {
targetParent = targetParent.lastChild;
targetParent = targetParent.lastElementChild; // IE9 or later only
}
// Note: Can use previousSibling and lastChild, not previousElementSibling and lastElementChild,
// since we have removed white space within elCnt. Hence support IE < 9
}
}
if (bindChar === "^") {
Expand Down
8 changes: 4 additions & 4 deletions jsviews.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion jsviews.min.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jsviews",
"version": "v1.0.10",
"version": "v1.0.11",
"description": "Next-generation MVVM and MVP framework - built on top of JsRender templates. Bringing templates to life...",
"main": "./jsviews.js",
"author": {
Expand Down Expand Up @@ -35,7 +35,7 @@
"browserify": "^11.0.1",
"glob-stream": "^5.0.0",
"gulp": "^3.9.0",
"jsrender": "^1.0.10",
"jsrender": "^1.0.11",
"qunit": "^0.7.6"
},
"dependencies": {
Expand Down
12 changes: 7 additions & 5 deletions test/browserify/bundles/1-bundle.js

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions test/browserify/bundles/10-errors-bundle.js

Large diffs are not rendered by default.

44 changes: 22 additions & 22 deletions test/browserify/bundles/11-errors-bundle.js

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions test/browserify/bundles/12-nested-bundle.js

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions test/browserify/bundles/2-bundle.js

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions test/browserify/bundles/3-bundle.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions test/browserify/bundles/4-bundle.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions test/browserify/bundles/5-bundle.js

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions test/browserify/bundles/6-bundle.js

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions test/browserify/bundles/7-bundle.js

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions test/browserify/bundles/8-bundle.js

Large diffs are not rendered by default.

32 changes: 17 additions & 15 deletions test/browserify/bundles/8B-bundle.js

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions test/browserify/bundles/9-bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/unit-tests-all-jsviews.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<script src="browserify/bundles/12-nested-bundle.js"></script>
<script src="browserify/tests-browserify-completed.js"></script>

<script id="myTmpl" type="text/x-jsrender">A_{{:name}}_B</script>
<script id="myTmpl" class="myTmpl" type="text/x-jsrender">A_{{:name}}_B</script>
<script id="my_tmpl" type="text/x-jsrender">A_{{:name}}_B</script>
<script id="my_tmpl2" type="text/x-jsrender">' " \ \' \"</script>
<script id="./test/templates/file/path.html" type="text/x-jsrender">ServerRenderedTemplate_{{:name}}_B</script>
Expand Down
2 changes: 1 addition & 1 deletion test/unit-tests-all-observable-render-views.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<script src="unit-tests/tests-jsrender-amd-scriptloader.js"></script>
<script src="unit-tests/tests-jsviews-amd-scriptloader.js"></script>

<script id="myTmpl" type="text/x-jsrender">A_{{:name}}_B</script>
<script id="myTmpl" class="myTmpl" type="text/x-jsrender">A_{{:name}}_B</script>
<script id="my_tmpl" type="text/x-jsrender">A_{{:name}}_B</script>
<script id="my_tmpl2" type="text/x-jsrender">' " \ \' \"</script>
<script id="./test/templates/file/path.html" type="text/x-jsrender">ServerRenderedTemplate_{{:name}}_B</script>
Expand Down
2 changes: 1 addition & 1 deletion test/unit-tests-all-render-observable-views.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<script src="unit-tests/tests-jsrender-amd-scriptloader.js"></script>
<script src="unit-tests/tests-jsviews-amd-scriptloader.js"></script>

<script id="myTmpl" type="text/x-jsrender">A_{{:name}}_B</script>
<script id="myTmpl" class="myTmpl" type="text/x-jsrender">A_{{:name}}_B</script>
<script id="my_tmpl" type="text/x-jsrender">A_{{:name}}_B</script>
<script id="my_tmpl2" type="text/x-jsrender">' " \ \' \"</script>
<script id="./test/templates/file/path.html" type="text/x-jsrender">ServerRenderedTemplate_{{:name}}_B</script>
Expand Down
2 changes: 1 addition & 1 deletion test/unit-tests-jsrender-no-jquery.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<script src="unit-tests/tests-jsrender-no-jquery.js"></script>

<script id="myTmpl" type="text/x-jsrender">A_{{:name}}_B</script>
<script id="myTmpl" class="myTmpl" type="text/x-jsrender">A_{{:name}}_B</script>
<script id="./test/templates/file/path.html" type="text/x-jsrender">ServerRenderedTemplate_{{:name}}_B</script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion test/unit-tests-jsrender-with-jquery.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<script src="unit-tests/tests-jsrender-with-jquery.js"></script>

<script id="myTmpl" type="text/x-jsrender">A_{{:name}}_B</script>
<script id="myTmpl" class="myTmpl" type="text/x-jsrender">A_{{:name}}_B</script>
<script id="my_tmpl" type="text/x-jsrender">A_{{:name}}_B</script>
<script id="my_tmpl2" type="text/x-jsrender">' " \ \' \"</script>
<script id="./test/templates/file/path.html" type="text/x-jsrender">ServerRenderedTemplate_{{:name}}_B</script>
Expand Down
2 changes: 1 addition & 1 deletion test/unit-tests-jsviews.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<script src="unit-tests/tests-jsviews.js"></script>

<script id="myTmpl" type="text/x-jsrender">A_{{:name}}_B</script>
<script id="myTmpl" class="myTmpl" type="text/x-jsrender">A_{{:name}}_B</script>
<script id="my_tmpl" type="text/x-jsrender">A_{{:name}}_B</script>
<script id="my_tmpl2" type="text/x-jsrender">' " \ \' \"</script>
</head>
Expand Down
2 changes: 1 addition & 1 deletion test/unit-tests-multiple-loads.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<script src="browserify/bundles/12-nested-bundle.js"></script>
<script src="browserify/tests-browserify-completed.js"></script>

<script id="myTmpl" type="text/x-jsrender">A_{{:name}}_B</script>
<script id="myTmpl" class="myTmpl" type="text/x-jsrender">A_{{:name}}_B</script>
<script id="my_tmpl" type="text/x-jsrender">A_{{:name}}_B</script>
<script id="my_tmpl2" type="text/x-jsrender">' " \ \' \"</script>
<script id="./test/templates/file/path.html" type="text/x-jsrender">ServerRenderedTemplate_{{:name}}_B</script>
Expand Down
15 changes: 9 additions & 6 deletions test/unit-tests/tests-jsobservable.js
Original file line number Diff line number Diff line change
Expand Up @@ -5082,8 +5082,10 @@ QUnit.test("$.views.viewModels", function(assert) {

QUnit.test("setProperty/insert/remove etc. using async or batched events", function(assert) {
// =============================== Arrange ===============================
var done = assert.async(),
count = 0,
var done;
if (assert.async) { done = assert.async() } else { stop() }

var count = 0,
batch = [],
person = { first: "Jo", last: "Blow" },
numbers = [0],
Expand Down Expand Up @@ -5151,14 +5153,15 @@ QUnit.test("setProperty/insert/remove etc. using async or batched events", funct
// ................................ Reset ................................
result = "";
$.unobserve();
done();
if (assert.async) { done() } else { start() }
}, 0);
});

QUnit.test("setProperty/insert/remove etc. using namespaces", function(assert) {
// =============================== Arrange ===============================
var done = assert.async(),
count = 0,
var done;
if (assert.async) { done = assert.async() } else { stop() }
var count = 0,
batch = [],
person = { first: "Jo", last: "Blow" },
numbers = [0],
Expand Down Expand Up @@ -5236,7 +5239,7 @@ QUnit.test("setProperty/insert/remove etc. using namespaces", function(assert) {
// ................................ Reset ................................
result = "";
$.unobserve();
done();
if (assert.async) { done() } else { start() }
}, 0);
});

Expand Down
21 changes: 12 additions & 9 deletions test/unit-tests/tests-jsrender-amd-scriptloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ if (!window.attachEvent || window.addEventListener) { // Running RequireJS in qu
QUnit.module("AMD Script Loader");

QUnit.test("Loading JsRender, without jQuery, using RequireJS", function(assert) {
var done = assert.async(),
jq = window.jQuery;
var done;
if (assert.async) { done = assert.async() } else { stop() }
var jq = window.jQuery;
undefine();

require(["//www.jsviews.com/download/jsrender.js"], function($) { // Or point to correct local path for jsrender.js on your system
Expand All @@ -24,13 +25,14 @@ QUnit.test("Loading JsRender, without jQuery, using RequireJS", function(assert)

var result = $.templates("Name: {{:name}}").render({name: "Jo"}) + " " + (!!$.jsrender);
assert.equal(result, "Name: Jo true", "JsRender Loaded");
done();
if (assert.async) { done() } else { start() }
});
});

QUnit.test("Loading JsRender and jQuery, without forcing load order, using RequireJS", function(assert) {
var done = assert.async(),
jq = window.jQuery;
var done;
if (assert.async) { done = assert.async() } else { stop() }
var jq = window.jQuery;
undefine();

// Note JsRender does not require jQuery - so its AMD definition does not specify jQuery dependency.
Expand All @@ -42,14 +44,15 @@ QUnit.test("Loading JsRender and jQuery, without forcing load order, using Requi

var result = $.templates("Name: {{:name}}").render({name: "Jo"}) + " " + ($ === $jq || !!$.jsrender);
assert.equal(result, "Name: Jo true", "JsRender Loaded");
done();
if (assert.async) { done() } else { start() }
});
});
});

QUnit.test("Loading JsRender with jQuery, and force jQuery to load before JsRender, using RequireJS", function(assert) {
var done = assert.async(),
jq = window.jQuery;
var done;
if (assert.async) { done = assert.async() } else { stop() }
var jq = window.jQuery;
undefine();

// Note JsRender does not require jQuery - so its AMD definition does not specify jQuery dependency.
Expand All @@ -63,7 +66,7 @@ QUnit.test("Loading JsRender with jQuery, and force jQuery to load before JsRend

var result = $.templates("Name: {{:name}}").render({name: "Jo"}) + " " + (jq !== $ && $ === window.jQuery && $ === $jq);
assert.equal(result, "Name: Jo true", "JsRender LoadedX");
done();
if (assert.async) { done() } else { start() }
});
});
});
Expand Down
57 changes: 56 additions & 1 deletion test/unit-tests/tests-jsrender-no-jquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -1261,6 +1261,7 @@ var teams = [

QUnit.module("api no jQuery");
QUnit.test("templates", function(assert) {

// ................................ Arrange ..................................
$.templates("./test/templates/file/path.html", null); // In case template has been stored in a previous test

Expand Down Expand Up @@ -1302,7 +1303,61 @@ QUnit.test("templates", function(assert) {
document.getElementById("./test/templates/file/path.html").removeAttribute("data-jsv-tmpl");
}

// =============================== Arrange ===============================
if (isBrowser) {
var tmplElem = document.getElementById("myTmpl");

// ................................ Act ..................................
tmpl0 = $.templates({markup: "#myTmpl"}); // Compile template declared in script block, but do not cache

// ............................... Assert .................................
assert.equal(tmpl0.render({name: "Jo0"}), "A_Jo0_B",
"Compile template declared in script block, without caching");

// ................................ Act ..................................
tmpl1 = $.templates("#myTmpl"); // Compile and cache, using "#myTmpl" as key);

// ............................... Assert .................................
assert.equal(tmpl1 !== tmpl0 && tmpl1.render({name: "Jo1"}), "A_Jo1_B",
"Compile template declared in script block, and cache on file path");

// ................................ Act ..................................
tmpl2 = $.templates("#myTmpl"); // Use cached template, accessed by $.templates["#myTmpl"]

// ............................... Assert .................................
assert.equal(tmpl2 === tmpl1 && tmpl1.render({name: "Jo2"}), "A_Jo2_B",
"Re-use cached template declared in script block");

// ................................ Act ..................................
var tmpl2b = $.templates(".myTmpl"); // Try to access script element by class selector - but fail because jQuery not loaded, so only "#xxx" selector is supported

// ............................... Assert .................................
if ($.fn || window._$ || tmpl2b === tmpl2) {
assert.equal(tmpl2b === tmpl2 && tmpl2b.render({name: "Jo2"}), "A_Jo2_B",
"Try to access script block using class selector - but not supported, by design, when jQuery not loaded");
} else {
assert.equal(tmpl2b !== tmpl2 && tmpl2b.render({name: "Jo2"}), ".myTmpl",
"Can access script block using class selector - when jQuery loaded");
}

// ................................ Act ..................................
tmpl2 = $.templates("#myAbsentTmpl");

// ............................... Assert .................................
assert.equal(tmpl2.render({name: "Jo2"}), "#myAbsentTmpl",
"Access missing script block template - renders as string");

// ................................ Act ..................................
tmpl3 = $.templates({markup: "#myTmpl"}); // Re-compile template but do not cache. Leave cached template.

// ............................... Assert .................................
assert.equal(tmpl3 !== tmpl0 && tmpl3 !== tmpl1 && tmpl3.render({name: "Jo3"}), "A_Jo3_B",
"Recompile template declared in script block, without caching");

// ................................ Reset ................................
tmplElem.removeAttribute("data-jsv-tmpl");
}

// =============================== Arrange ===============================
tmplString = "A_{{:name}}_B";

var tmpl = $.templates(tmplString);
Expand Down
Loading

0 comments on commit 43c4710

Please sign in to comment.