Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

can-stache-bindings

Package Overview
Dependencies
Maintainers
16
Versions
219
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

can-stache-bindings - npm Package Compare versions

Comparing version 5.0.0-pre.1 to 5.0.0-pre.2

12

can-stache-bindings.js

@@ -1077,3 +1077,3 @@ "use strict";

//!steal-remove-end
var bindingOptions = {

@@ -1090,4 +1090,5 @@ child: childObservable,

priority: bindingContext.parentNodeList ? bindingContext.parentNodeList.nesting + 1 : undefined,
queue: "domUI",
sticky: siblingBindingData.parent.syncSibling ? "childSticksToParent" : undefined
queue: "dom",
sticky: siblingBindingData.parent.syncSibling ? "childSticksToParent" : undefined,
element: bindingContext.element
};

@@ -1113,7 +1114,8 @@

};
bindingOptions.updateChildName = tagStart+" "+nodeHTML+"> updates "+
bindingOptions.debugName = tagStart+" "+nodeHTML+">";
bindingOptions.updateChildName = bindingOptions.debugName+" updates "+
makeUpdateName(siblingBindingData.child.source, siblingBindingData.child.name)+
" from "+makeUpdateName(siblingBindingData.parent.source, siblingBindingData.parent.name);
bindingOptions.updateParentName = tagStart+" "+nodeHTML+"> updates "+
bindingOptions.updateParentName = bindingOptions.debugName+" updates "+
makeUpdateName(siblingBindingData.parent.source, siblingBindingData.parent.name)+

@@ -1120,0 +1122,0 @@ " from "+makeUpdateName(siblingBindingData.child.source, siblingBindingData.child.name);

{
"name": "can-stache-bindings",
"version": "5.0.0-pre.1",
"version": "5.0.0-pre.2",
"description": "Default binding syntaxes for can-stache",

@@ -36,4 +36,4 @@ "homepage": "https://canjs.com/doc/can-stache-bindings.html",

"can-attribute-observable": "canjs/can-attribute-observable#major",
"can-bind": "^1.4.0",
"can-diff": "github:canjs/can-diff#patch-sort",
"can-bind": "^1.5.0",
"can-diff": "^1.5.0",
"can-dom-data": "^1.0.1",

@@ -62,3 +62,4 @@ "can-dom-events": "^1.3.3",

"can-globals": "^1.0.0",
"can-test-helpers": "^1.1.1",
"can-simple-dom": "canjs/can-simple-dom#compare-document-position",
"can-test-helpers": "^1.1.4",
"can-vdom": "^4.0.0",

@@ -68,3 +69,3 @@ "detect-cyclic-packages": "^1.1.0",

"steal": "^2.2.1",
"steal-qunit": "^1.0.1",
"steal-qunit": "^2.0.0",
"steal-tools": "^2.2.1",

@@ -71,0 +72,0 @@ "testee": "^0.9.0"

@@ -36,3 +36,4 @@ var QUnit = require('steal-qunit');

test("basics", 5, function(){
QUnit.test("basics", function(assert) {
assert.expect(5);

@@ -56,3 +57,3 @@ var viewModel = new SimpleMap({

methodD: function(){
QUnit.ok(true, "on:vmevent bindings work");
assert.ok(true, "on:vmevent bindings work");
}

@@ -69,3 +70,3 @@ });

QUnit.deepEqual(parent.get(), {
assert.deepEqual(parent.get(), {
valueA: 'A',

@@ -76,3 +77,3 @@ valueB: 'toParent',

QUnit.deepEqual(viewModel.get(), {
assert.deepEqual(viewModel.get(), {
toChild: "A",

@@ -90,3 +91,3 @@ toParent: "toParent",

QUnit.deepEqual(viewModel.get(), {
assert.deepEqual(viewModel.get(), {
toChild: "a",

@@ -104,3 +105,3 @@ toParent: "toParent",

QUnit.deepEqual(parent.get(), {
assert.deepEqual(parent.get(), {
valueA: "a",

@@ -115,6 +116,6 @@ valueB: "to-parent",

test("getSiblingBindingData", function(){
QUnit.test("getSiblingBindingData", function(assert) {
var info = stacheBindings.getSiblingBindingData({name: "foo-ed:from", value: "bar"});
deepEqual(siblingsDataToInfo(info), {
assert.deepEqual(siblingsDataToInfo(info), {
parent: "scope",

@@ -133,3 +134,3 @@ child: "viewModelOrAttribute",

info = stacheBindings.getSiblingBindingData({name: "foo-ed:bind", value: "bar"});
deepEqual(siblingsDataToInfo(info), {
assert.deepEqual(siblingsDataToInfo(info), {
parent: "scope",

@@ -148,3 +149,3 @@ child: "viewModelOrAttribute",

info = stacheBindings.getSiblingBindingData({name: "foo-ed:to", value: "bar"});
deepEqual(siblingsDataToInfo(info), {
assert.deepEqual(siblingsDataToInfo(info), {
parent: "scope",

@@ -163,3 +164,3 @@ child: "viewModelOrAttribute",

info = stacheBindings.getSiblingBindingData({name: "foo-ed:from", value: "bar"}, {favorViewModel: true});
deepEqual(siblingsDataToInfo(info), {
assert.deepEqual(siblingsDataToInfo(info), {
parent: "scope",

@@ -178,3 +179,3 @@ child: "viewModel",

info = stacheBindings.getSiblingBindingData({name: "foo-ed:bind", value: "bar"}, {favorViewModel: true});
deepEqual(siblingsDataToInfo(info), {
assert.deepEqual(siblingsDataToInfo(info), {
parent: "scope",

@@ -193,3 +194,3 @@ child: "viewModel",

info = stacheBindings.getSiblingBindingData({name: "foo-ed:to", value: "bar"}, {favorViewModel: true});
deepEqual(siblingsDataToInfo(info), {
assert.deepEqual(siblingsDataToInfo(info), {
parent: "scope",

@@ -208,5 +209,5 @@ child: "viewModel",

test("getSiblingBindingData for vm:", function() {
QUnit.test("getSiblingBindingData for vm:", function(assert) {
var info = stacheBindings.getSiblingBindingData({name: "vm:foo-ed:from", value: "bar"});
deepEqual(siblingsDataToInfo(info), {
assert.deepEqual(siblingsDataToInfo(info), {
parent: "scope",

@@ -225,3 +226,3 @@ child: "viewModel",

info = stacheBindings.getSiblingBindingData({name: "vm:foo-ed:bind", value: "bar"});
deepEqual(siblingsDataToInfo(info), {
assert.deepEqual(siblingsDataToInfo(info), {
parent: "scope",

@@ -240,3 +241,3 @@ child: "viewModel",

info = stacheBindings.getSiblingBindingData({name: "vm:foo-ed:to", value: "bar"});
deepEqual(siblingsDataToInfo(info), {
assert.deepEqual(siblingsDataToInfo(info), {
parent: "scope",

@@ -256,3 +257,3 @@ child: "viewModel",

deepEqual(siblingsDataToInfo(info), {
assert.deepEqual(siblingsDataToInfo(info), {
parent: "scope",

@@ -271,3 +272,3 @@ child: "viewModel",

info = stacheBindings.getSiblingBindingData({name: "vm:foo-ed:bind", value: "bar"}, {favorViewModel: true});
deepEqual(siblingsDataToInfo(info), {
assert.deepEqual(siblingsDataToInfo(info), {
parent: "scope",

@@ -286,3 +287,3 @@ child: "viewModel",

info = stacheBindings.getSiblingBindingData({name: "vm:foo-ed:to", value: "bar"}, {favorViewModel: true});
deepEqual(siblingsDataToInfo(info), {
assert.deepEqual(siblingsDataToInfo(info), {
parent: "scope",

@@ -301,5 +302,5 @@ child: "viewModel",

test("getSiblingBindingData for el:", function() {
QUnit.test("getSiblingBindingData for el:", function(assert) {
var info = stacheBindings.getSiblingBindingData({name: "el:foo-ed:from", value: "bar"});
deepEqual(siblingsDataToInfo(info), {
assert.deepEqual(siblingsDataToInfo(info), {
parent: "scope",

@@ -318,3 +319,3 @@ child: "attribute",

info = stacheBindings.getSiblingBindingData({name: "el:foo-ed:bind", value: "bar"});
deepEqual(siblingsDataToInfo(info), {
assert.deepEqual(siblingsDataToInfo(info), {
parent: "scope",

@@ -333,3 +334,3 @@ child: "attribute",

info = stacheBindings.getSiblingBindingData({name: "el:foo-ed:to", value: "bar"});
deepEqual(siblingsDataToInfo(info), {
assert.deepEqual(siblingsDataToInfo(info), {
parent: "scope",

@@ -348,3 +349,3 @@ child: "attribute",

info = stacheBindings.getSiblingBindingData({name: "el:foo-ed:from", value: "bar"}, null, null, null, true);
deepEqual(siblingsDataToInfo(info), {
assert.deepEqual(siblingsDataToInfo(info), {
parent: "scope",

@@ -363,3 +364,3 @@ child: "attribute",

info = stacheBindings.getSiblingBindingData({name: "el:foo-ed:bind", value: "bar"}, null, null, null, true);
deepEqual(siblingsDataToInfo(info), {
assert.deepEqual(siblingsDataToInfo(info), {
parent: "scope",

@@ -378,3 +379,3 @@ child: "attribute",

info = stacheBindings.getSiblingBindingData({name: "el:foo-ed:to", value: "bar"}, null, null, null, true);
deepEqual(siblingsDataToInfo(info), {
assert.deepEqual(siblingsDataToInfo(info), {
parent: "scope",

@@ -393,6 +394,6 @@ child: "attribute",

QUnit.test("getSiblingBindingData works for value:to:on:click (#269)", function(){
QUnit.test("getSiblingBindingData works for value:to:on:click (#269)", function(assert) {
var info = stacheBindings.getSiblingBindingData({name: "value:to:on:click", value: "bar"});
deepEqual(siblingsDataToInfo(info), {
assert.deepEqual(siblingsDataToInfo(info), {
parent: "scope",

@@ -412,6 +413,6 @@ child: "viewModelOrAttribute",

QUnit.test("decode values with To (#504)", function(){
QUnit.test("decode values with To (#504)", function(assert) {
var name = encoder.encode("goToHome:to");
var info = stacheBindings.getSiblingBindingData({name: name, value: "bar"});
deepEqual(siblingsDataToInfo(info), {
assert.deepEqual(siblingsDataToInfo(info), {
parent: "scope",

@@ -431,3 +432,3 @@ child: "viewModelOrAttribute",

canTestHelpers.dev.devOnlyTest("warning when binding to non-existing value (#136) (#119)", function() {
canTestHelpers.dev.devOnlyTest("warning when binding to non-existing value (#136) (#119)", function(assert) {
var teardown = canTestHelpers.dev.willWarn('This element does not have a viewModel. (Attempting to bind `target:vm:bind="source.bar"`)');

@@ -439,7 +440,7 @@

template(map);
QUnit.equal(teardown(), 1, 'warning shown');
assert.equal(teardown(), 1, 'warning shown');
});
QUnit.test("parent stache is able to teardown child bindings (#278)", function(){
QUnit.test("parent stache is able to teardown child bindings (#278)", function(assert) {
var map = new SimpleMap({value: "VALUE"});

@@ -454,6 +455,6 @@

QUnit.equal(input.value, "VALUE", "value set initially");
assert.equal(input.value, "VALUE", "value set initially");
map.set("value","");
QUnit.equal(input.value, "VALUE", "value should not have been updated");
assert.equal(input.value, "VALUE", "value should not have been updated");
});

@@ -475,9 +476,9 @@

testHelpers.afterMutation(function() {
testHelpers.afterMutation(function () {
map.set("value", "second");
QUnit.equal(input.value, "second", "value should have been updated");
assert.equal(input.value, "second", "value should have been updated");
input.value = "third";
domEvents.dispatch(input, "change");
QUnit.equal(map.get("value"), "third", "map should have been updated");
assert.equal(map.get("value"), "third", "map should have been updated");

@@ -484,0 +485,0 @@ done();

@@ -26,3 +26,3 @@ var QUnit = require('steal-qunit');

QUnit.test("<input text> value:bind input text", function() {
QUnit.test("<input text> value:bind input text", function(assert) {
var template = stache("<input value:bind='age'/>");

@@ -38,11 +38,11 @@

var input = ta.getElementsByTagName("input")[0];
equal(input.value, "", "input value set correctly if key does not exist in map");
assert.equal(input.value, "", "input value set correctly if key does not exist in map");
map.set("age", "30");
equal(input.value, "30", "input value set correctly");
assert.equal(input.value, "30", "input value set correctly");
map.set("age", "31");
equal(input.value, "31", "input value update correctly");
assert.equal(input.value, "31", "input value update correctly");

@@ -53,7 +53,7 @@ input.value = "32";

equal(map.get("age"), "32", "updated from input");
assert.equal(map.get("age"), "32", "updated from input");
});
QUnit.test('<input text> el:prop:to/:from/:bind work (#280)', function() {
QUnit.test('<input text> el:prop:to/:from/:bind work (#280)', function(assert) {
var template = stache(

@@ -79,34 +79,34 @@ "<input el:value:to='scope1' value='1'/>" +

// el:value:to
equal(scope.attr('scope1'), '1', 'el:value:to - scope value set from attribute');
assert.equal(scope.attr('scope1'), '1', 'el:value:to - scope value set from attribute');
inputTo.value = '4';
domEvents.dispatch(inputTo, 'change');
equal(scope.attr('scope1'), '4', 'el:value:to - scope updated when attribute changed');
assert.equal(scope.attr('scope1'), '4', 'el:value:to - scope updated when attribute changed');
scope.attr('scope1', 'scope4');
equal(inputTo.value, '4', 'el:value:to - attribute not updated when scope changed');
assert.equal(inputTo.value, '4', 'el:value:to - attribute not updated when scope changed');
// el:value:from
equal(inputFrom.value, 'scope2', 'el:value:from - attribute set from scope');
assert.equal(inputFrom.value, 'scope2', 'el:value:from - attribute set from scope');
inputFrom.value = 'scope5';
domEvents.dispatch(inputFrom, 'change');
equal(scope.attr('scope2'), 'scope2', 'el:value:from - scope not updated when attribute changed');
assert.equal(scope.attr('scope2'), 'scope2', 'el:value:from - scope not updated when attribute changed');
scope.attr('scope2', 'scope6');
equal(inputFrom.value, 'scope6', 'el:value:from - attribute updated when scope changed');
assert.equal(inputFrom.value, 'scope6', 'el:value:from - attribute updated when scope changed');
// el:value:bind
equal(inputBind.value, 'scope3', 'el:value:bind - attribute set from scope prop (parent -> child wins)');
assert.equal(inputBind.value, 'scope3', 'el:value:bind - attribute set from scope prop (parent -> child wins)');
inputBind.value = 'scope6';
domEvents.dispatch(inputBind, 'change');
equal(scope.attr('scope3'), 'scope6', 'el:value:bind - scope updated when attribute changed');
assert.equal(scope.attr('scope3'), 'scope6', 'el:value:bind - scope updated when attribute changed');
scope.attr('scope3', 'scope7');
equal(inputBind.value, 'scope7', 'el:value:bind - attribute updated when scope changed');
assert.equal(inputBind.value, 'scope7', 'el:value:bind - attribute updated when scope changed');
});
if (System.env !== 'canjs-test') {
test("<input text> dynamic attribute bindings (#2016)", function(assert){
QUnit.test("<input text> dynamic attribute bindings (#2016)", function(assert){
var done = assert.async();

@@ -123,7 +123,7 @@ var template = stache("<input value:bind='{{propName}}'/>");

var input = ta.getElementsByTagName("input")[0];
testHelpers.afterMutation(function() {
equal(input.value, "Justin", "input value set correctly if key does not exist in map");
testHelpers.afterMutation(function () {
assert.equal(input.value, "Justin", "input value set correctly if key does not exist in map");
map.set('propName','last');
testHelpers.afterMutation(function(){
equal(input.value, "Meyer", "input value set correctly if key does not exist in map");
testHelpers.afterMutation(function (){
assert.equal(input.value, "Meyer", "input value set correctly if key does not exist in map");

@@ -133,4 +133,4 @@ input.value = "Lueke";

testHelpers.afterMutation(function() {
equal(map.get("last"), "Lueke", "updated from input");
testHelpers.afterMutation(function () {
assert.equal(map.get("last"), "Lueke", "updated from input");
done();

@@ -143,3 +143,3 @@ });

test("value:bind compute rejects new value (#887)", function() {
QUnit.test("value:bind compute rejects new value (#887)", function(assert) {
var template = stache("<input value:bind='age'/>");

@@ -172,7 +172,7 @@

equal(compute.get(), 30, "Still the old value");
equal(input.value, "30", "Text input has also not changed");
assert.equal(compute.get(), 30, "Still the old value");
assert.equal(input.value, "30", "Text input has also not changed");
});
test("value:from works with camelCase and kebab-case properties", function() {
QUnit.test("value:from works with camelCase and kebab-case properties", function(assert) {
var template = stache(

@@ -193,33 +193,33 @@ "<input value:from='theProp'/>" +

equal(camelPropInput.value, "", "input bound to camelCase prop value set correctly if camelCase key does not exist in map");
equal(kebabPropInput.value, "", "input bound to kebab-case prop value set correctly if kebab-case key does not exist in map");
assert.equal(camelPropInput.value, "", "input bound to camelCase prop value set correctly if camelCase key does not exist in map");
assert.equal(kebabPropInput.value, "", "input bound to kebab-case prop value set correctly if kebab-case key does not exist in map");
map.attr("theProp", "30");
equal(camelPropInput.value, "30", "input bound to camelCase prop value set correctly when camelCase prop changes");
equal(kebabPropInput.value, "", "input bound to kebab-case prop value not updated when camelCase prop changes");
assert.equal(camelPropInput.value, "30", "input bound to camelCase prop value set correctly when camelCase prop changes");
assert.equal(kebabPropInput.value, "", "input bound to kebab-case prop value not updated when camelCase prop changes");
map.attr("theProp", "31");
equal(camelPropInput.value, "31", "input bound to camelCase prop value updated correctly when camelCase prop changes");
ok(!kebabPropInput.value, "input bound to kebab-case prop value not updated when camelCase prop changes");
assert.equal(camelPropInput.value, "31", "input bound to camelCase prop value updated correctly when camelCase prop changes");
assert.ok(!kebabPropInput.value, "input bound to kebab-case prop value not updated when camelCase prop changes");
camelPropInput.value = "32";
domEvents.dispatch(camelPropInput, "change");
equal(map.attr("theProp"), "31", "camelCase prop NOT updated when input bound to camelCase prop changes");
ok(!map.attr("the-prop"), "kebabCase prop NOT updated when input bound to camelCase prop changes");
assert.equal(map.attr("theProp"), "31", "camelCase prop NOT updated when input bound to camelCase prop changes");
assert.ok(!map.attr("the-prop"), "kebabCase prop NOT updated when input bound to camelCase prop changes");
map.attr("the-prop", "33");
equal(kebabPropInput.value, "33", "input bound to kebab-case prop value set correctly when kebab-case prop changes");
equal(camelPropInput.value, "32", "input bound to camelCase prop value not updated when kebab-case prop changes");
assert.equal(kebabPropInput.value, "33", "input bound to kebab-case prop value set correctly when kebab-case prop changes");
assert.equal(camelPropInput.value, "32", "input bound to camelCase prop value not updated when kebab-case prop changes");
map.attr("the-prop", "34");
equal(kebabPropInput.value, "34", "input bound to kebab-case prop value updated correctly when kebab-case prop changes");
equal(camelPropInput.value, "32", "input bound to camelCase prop value not updated when kebab-case prop changes");
assert.equal(kebabPropInput.value, "34", "input bound to kebab-case prop value updated correctly when kebab-case prop changes");
assert.equal(camelPropInput.value, "32", "input bound to camelCase prop value not updated when kebab-case prop changes");
kebabPropInput.value = "35";
domEvents.dispatch(kebabPropInput, "change");
equal(map.attr("the-prop"), "34", "kebab-case prop NOT updated from input bound to kebab-case prop");
equal(map.attr("theProp"), "31", "camelCase prop NOT updated from input bound to kebab-case prop");
assert.equal(map.attr("the-prop"), "34", "kebab-case prop NOT updated from input bound to kebab-case prop");
assert.equal(map.attr("theProp"), "31", "camelCase prop NOT updated from input bound to kebab-case prop");
});
test("value:to works with camelCase and kebab-case properties", function() {
QUnit.test("value:to works with camelCase and kebab-case properties", function(assert) {
var template = stache(

@@ -242,21 +242,21 @@ "<input value:to='theProp'/>" +

domEvents.dispatch(camelPropInput, "change");
equal(map.attr("theProp"), "32", "camelCaseProp updated from input bound to camelCase Prop");
ok(!map.attr("the-prop"), "kebabCaseProp NOT updated from input bound to camelCase Prop");
assert.equal(map.attr("theProp"), "32", "camelCaseProp updated from input bound to camelCase Prop");
assert.ok(!map.attr("the-prop"), "kebabCaseProp NOT updated from input bound to camelCase Prop");
map.attr("theProp", "30");
equal(camelPropInput.value, "32", "input bound to camelCase Prop value NOT updated when camelCase prop changes");
ok(!kebabPropInput.value, "input bound to kebabCase Prop value NOT updated when camelCase prop changes");
assert.equal(camelPropInput.value, "32", "input bound to camelCase Prop value NOT updated when camelCase prop changes");
assert.ok(!kebabPropInput.value, "input bound to kebabCase Prop value NOT updated when camelCase prop changes");
kebabPropInput.value = "33";
domEvents.dispatch(kebabPropInput, "change");
equal(map.attr("the-prop"), "33", "kebabCaseProp updated from input bound to kebabCase Prop");
equal(map.attr("theProp"), "30", "camelCaseProp NOT updated from input bound to camelCase Prop");
assert.equal(map.attr("the-prop"), "33", "kebabCaseProp updated from input bound to kebabCase Prop");
assert.equal(map.attr("theProp"), "30", "camelCaseProp NOT updated from input bound to camelCase Prop");
map.attr("theProp", "34");
equal(kebabPropInput.value, "33", "input bound to kebabCase Prop value NOT updated when kebabCase prop changes");
equal(camelPropInput.value, "32", "input bound to camelCase Prop value NOT updated when kebabCase prop changes");
assert.equal(kebabPropInput.value, "33", "input bound to kebabCase Prop value NOT updated when kebabCase prop changes");
assert.equal(camelPropInput.value, "32", "input bound to camelCase Prop value NOT updated when kebabCase prop changes");
});
test("value:bind works with camelCase and kebab-case properties", function() {
QUnit.test("value:bind works with camelCase and kebab-case properties", function(assert) {
var template = stache(

@@ -279,21 +279,21 @@ "<input value:bind='theProp'/>" +

domEvents.dispatch(camelPropInput, "change");
equal(map.attr("theProp"), "32", "camelCaseProp updated from input bound to camelCase Prop");
ok(!map.attr("the-prop"), "kebabCaseProp NOT updated from input bound to camelCase Prop");
assert.equal(map.attr("theProp"), "32", "camelCaseProp updated from input bound to camelCase Prop");
assert.ok(!map.attr("the-prop"), "kebabCaseProp NOT updated from input bound to camelCase Prop");
map.attr("theProp", "30");
equal(camelPropInput.value, "30", "input bound to camelCase Prop value updated when camelCase prop changes");
ok(!kebabPropInput.value, "input bound to kebabCase Prop value NOT updated when camelCase prop changes");
assert.equal(camelPropInput.value, "30", "input bound to camelCase Prop value updated when camelCase prop changes");
assert.ok(!kebabPropInput.value, "input bound to kebabCase Prop value NOT updated when camelCase prop changes");
kebabPropInput.value = "33";
domEvents.dispatch(kebabPropInput, "change");
equal(map.attr("the-prop"), "33", "kebabCaseProp updated from input bound to kebabCase Prop");
equal(map.attr("theProp"), "30", "camelCaseProp NOT updated from input bound to camelCase Prop");
assert.equal(map.attr("the-prop"), "33", "kebabCaseProp updated from input bound to kebabCase Prop");
assert.equal(map.attr("theProp"), "30", "camelCaseProp NOT updated from input bound to camelCase Prop");
map.attr("theProp", "34");
equal(kebabPropInput.value, "33", "input bound to kebabCase Prop value NOT updated when kebabCase prop changes");
equal(camelPropInput.value, "34", "input bound to camelCase Prop value updated when kebabCase prop changes");
assert.equal(kebabPropInput.value, "33", "input bound to kebabCase Prop value NOT updated when kebabCase prop changes");
assert.equal(camelPropInput.value, "34", "input bound to camelCase Prop value updated when kebabCase prop changes");
});
test("Bracket expression with dot and no explicit root and value:bind", function () {
QUnit.test("Bracket expression with dot and no explicit root and value:bind", function(assert) {
var template;

@@ -314,11 +314,11 @@ var div = this.fixture;

equal(input.value, "", "input value set correctly if key does not exist in map");
assert.equal(input.value, "", "input value set correctly if key does not exist in map");
data.set("two.hops", "slide to the left");
equal(input.value, "slide to the left", "input value set correctly");
assert.equal(input.value, "slide to the left", "input value set correctly");
data.set("two.hops", "slide to the right");
equal(input.value, "slide to the right", "input value update correctly");
assert.equal(input.value, "slide to the right", "input value update correctly");

@@ -329,7 +329,7 @@ input.value = "REVERSE REVERSE";

equal(data.get("two.hops"), "REVERSE REVERSE", "updated from input");
assert.equal(data.get("two.hops"), "REVERSE REVERSE", "updated from input");
});
test("Bracket expression with colon and no explicit root and value:bind", function () {
QUnit.test("Bracket expression with colon and no explicit root and value:bind", function(assert) {
var template;

@@ -349,11 +349,11 @@ var div = this.fixture;

equal(input.value, "", "input value set correctly if key does not exist in map");
assert.equal(input.value, "", "input value set correctly if key does not exist in map");
data.set("two:hops", "slide to the left");
equal(input.value, "slide to the left", "input value set correctly");
assert.equal(input.value, "slide to the left", "input value set correctly");
data.set("two:hops", "slide to the right");
equal(input.value, "slide to the right", "input value update correctly");
assert.equal(input.value, "slide to the right", "input value update correctly");

@@ -364,7 +364,7 @@ input.value = "REVERSE REVERSE";

equal(data.get("two:hops"), "REVERSE REVERSE", "updated from input");
assert.equal(data.get("two:hops"), "REVERSE REVERSE", "updated from input");
});
QUnit.test('el:prop:to/:from/:bind work (#280)', function() {
QUnit.test('el:prop:to/:from/:bind work (#280)', function(assert) {
var template = stache(

@@ -390,34 +390,34 @@ "<input el:value:to='scope1' value='1'/>" +

// el:value:to
equal(scope.attr('scope1'), '1', 'el:value:to - scope value set from attribute');
assert.equal(scope.attr('scope1'), '1', 'el:value:to - scope value set from attribute');
inputTo.value = '4';
domEvents.dispatch(inputTo, 'change');
equal(scope.attr('scope1'), '4', 'el:value:to - scope updated when attribute changed');
assert.equal(scope.attr('scope1'), '4', 'el:value:to - scope updated when attribute changed');
scope.attr('scope1', 'scope4');
equal(inputTo.value, '4', 'el:value:to - attribute not updated when scope changed');
assert.equal(inputTo.value, '4', 'el:value:to - attribute not updated when scope changed');
// el:value:from
equal(inputFrom.value, 'scope2', 'el:value:from - attribute set from scope');
assert.equal(inputFrom.value, 'scope2', 'el:value:from - attribute set from scope');
inputFrom.value = 'scope5';
domEvents.dispatch(inputFrom, 'change');
equal(scope.attr('scope2'), 'scope2', 'el:value:from - scope not updated when attribute changed');
assert.equal(scope.attr('scope2'), 'scope2', 'el:value:from - scope not updated when attribute changed');
scope.attr('scope2', 'scope6');
equal(inputFrom.value, 'scope6', 'el:value:from - attribute updated when scope changed');
assert.equal(inputFrom.value, 'scope6', 'el:value:from - attribute updated when scope changed');
// el:value:bind
equal(inputBind.value, 'scope3', 'el:value:bind - attribute set from scope prop (parent -> child wins)');
assert.equal(inputBind.value, 'scope3', 'el:value:bind - attribute set from scope prop (parent -> child wins)');
inputBind.value = 'scope6';
domEvents.dispatch(inputBind, 'change');
equal(scope.attr('scope3'), 'scope6', 'el:value:bind - scope updated when attribute changed');
assert.equal(scope.attr('scope3'), 'scope6', 'el:value:bind - scope updated when attribute changed');
scope.attr('scope3', 'scope7');
equal(inputBind.value, 'scope7', 'el:value:bind - attribute updated when scope changed');
assert.equal(inputBind.value, 'scope7', 'el:value:bind - attribute updated when scope changed');
});
test("<input text> two-way - DOM - input text (#1700)", function() {
QUnit.test("<input text> two-way - DOM - input text (#1700)", function(assert) {

@@ -434,18 +434,18 @@ var template = stache("<input value:bind='age'/>");

var input = ta.getElementsByTagName("input")[0];
equal(input.value, "", "input value set correctly if key does not exist in map");
assert.equal(input.value, "", "input value set correctly if key does not exist in map");
map.attr("age", "30");
stop();
testHelpers.afterMutation(function() {
start();
equal(input.value, "30", "input value set correctly");
var done = assert.async();
testHelpers.afterMutation(function () {
assert.equal(input.value, "30", "input value set correctly");
map.attr("age", "31");
stop();
testHelpers.afterMutation(function() {
start();
equal(input.value, "31", "input value update correctly");
testHelpers.afterMutation(function () {
assert.equal(input.value, "31", "input value update correctly");
input.value = "32";

@@ -455,6 +455,6 @@

stop();
testHelpers.afterMutation(function() {
start();
equal(map.attr("age"), "32", "updated from input");
testHelpers.afterMutation(function () {
done();
assert.equal(map.attr("age"), "32", "updated from input");
});

@@ -465,13 +465,13 @@ });

QUnit.test("errors subproperties of undefined properties (#298)", function() {
QUnit.test("errors subproperties of undefined properties (#298)", function(assert) {
try {
stache("<input value:to='prop.subprop'/>")();
ok(true, "renderer was made without error");
assert.ok(true, "renderer was made without error");
}
catch(e) {
ok(false, e.message);
assert.ok(false, e.message);
}
});
test("updates happen on two-way even when one binding is satisfied", function(assert) {
QUnit.test("updates happen on two-way even when one binding is satisfied", function(assert) {
var done = assert.async();

@@ -529,3 +529,3 @@ var template = stache('<input value:bind="firstName"/>');

var input = this.fixture.firstChild;
testHelpers.afterMutation(function() {
testHelpers.afterMutation(function () {

@@ -555,3 +555,3 @@ assert.equal(input.value, "jeffrey");

test("value:bind memory leak (#2270)", function() {
QUnit.test("value:bind memory leak (#2270)", function(assert) {

@@ -568,8 +568,8 @@

QUnit.stop();
var done = assert.async();
testHelpers.afterMutation(function(){
testHelpers.afterMutation(function (){
domMutateNode.removeChild.call(ta, ta.firstChild);
// still 1 binding, should be 0
testHelpers.afterMutation(function(){
testHelpers.afterMutation(function (){
var checkCount = 0;

@@ -580,9 +580,9 @@ var checkLifecycleBindings = function(){

if( meta.handlers.get([]).length === 0 ) {
QUnit.ok(true, "no bindings");
start();
assert.ok(true, "no bindings");
done();
} else {
checkCount++;
if (checkCount > 5) {
QUnit.ok(false, "lifecycle bindings still existed after timeout");
return start();
assert.ok(false, "lifecycle bindings still existed after timeout");
return done();
}

@@ -598,3 +598,3 @@ setTimeout(checkLifecycleBindings, 1000);

test("converters work (#2299)", function(){
QUnit.test("converters work (#2299)", function(assert) {
stache.registerConverter("numberToString",{

@@ -615,9 +615,9 @@ get: function(source){

equal(frag.firstChild.value, "25");
equal(map.get("age"), 25);
assert.equal(frag.firstChild.value, "25");
assert.equal(map.get("age"), 25);
map.set("age",33);
equal(frag.firstChild.value, "33");
equal(map.get("age"), 33);
assert.equal(frag.firstChild.value, "33");
assert.equal(map.get("age"), 33);

@@ -628,7 +628,7 @@ frag.firstChild.value = "1";

stop();
testHelpers.afterMutation(function() {
start();
equal(frag.firstChild.value, "1");
equal(map.get("age"), 1);
var done = assert.async();
testHelpers.afterMutation(function () {
done();
assert.equal(frag.firstChild.value, "1");
assert.equal(map.get("age"), 1);
});

@@ -638,3 +638,3 @@

testIfRealDocument("<input radio> checked:bind should trigger a radiochange event for radio buttons", function() {
testIfRealDocument("<input radio> checked:bind should trigger a radiochange event for radio buttons", function(assert) {
// NOTE: `testIfRealDocument` is used because the vdom does not simulate document event dispatch

@@ -675,10 +675,10 @@ var template = stache([

equal(text(fooText), 'false', 'foo text is false');
equal(text(barText), 'true', 'bar text is true');
assert.equal(text(fooText), 'false', 'foo text is false');
assert.equal(text(barText), 'true', 'bar text is true');
equal(data.get("foo"), false);
equal(data.get("bar"), true);
assert.equal(data.get("foo"), false);
assert.equal(data.get("bar"), true);
});
QUnit.test('<input radio> change event handler set up when binding on radiochange (#206)', function() {
QUnit.test('<input radio> change event handler set up when binding on radiochange (#206)', function(assert) {

@@ -697,6 +697,6 @@ var template = stache('<input type="radio" checked:bind="attending" />');

QUnit.equal(map.get('attending'), true, "now it is true");
assert.equal(map.get('attending'), true, "now it is true");
});
test('<input checkbox> one-way - DOM - with undefined (#135)', function() {
QUnit.test('<input checkbox> one-way - DOM - with undefined (#135)', function(assert) {
var data = new SimpleMap({

@@ -710,6 +710,6 @@ completed: undefined

var input = this.fixture.getElementsByTagName('input')[0];
equal(input.checked, false, 'checkbox value should be false for undefined');
assert.equal(input.checked, false, 'checkbox value should be false for undefined');
});
test('<input checkbox> two-way - DOM - with truthy and falsy values binds to checkbox (#1700)', function() {
QUnit.test('<input checkbox> two-way - DOM - with truthy and falsy values binds to checkbox (#1700)', function(assert) {
var data = new SimpleMap({

@@ -723,13 +723,13 @@ completed: 1

var input = this.fixture.getElementsByTagName('input')[0];
equal(input.checked, true, 'checkbox value bound (via attr check)');
assert.equal(input.checked, true, 'checkbox value bound (via attr check)');
data.attr('completed', 0);
stop();
var done = assert.async();
testHelpers.afterMutation(function() {
start();
equal(input.checked, false, 'checkbox value bound (via attr check)');
testHelpers.afterMutation(function () {
done();
assert.equal(input.checked, false, 'checkbox value bound (via attr check)');
});
});
test("<input checkbox> checkboxes with checked:bind bind properly (#628)", function() {
QUnit.test("<input checkbox> checkboxes with checked:bind bind properly (#628)", function(assert) {
var data = new SimpleMap({

@@ -743,17 +743,17 @@ completed: true

var input = this.fixture.getElementsByTagName('input')[0];
equal(input.checked, data.get('completed'), 'checkbox value bound (via attr check)');
assert.equal(input.checked, data.get('completed'), 'checkbox value bound (via attr check)');
data.attr('completed', false);
equal(input.checked, data.get('completed'), 'checkbox value bound (via attr uncheck)');
assert.equal(input.checked, data.get('completed'), 'checkbox value bound (via attr uncheck)');
input.checked = true;
domEvents.dispatch(input, 'change');
equal(input.checked, true, 'checkbox value bound (via check)');
equal(data.get('completed'), true, 'checkbox value bound (via check)');
assert.equal(input.checked, true, 'checkbox value bound (via check)');
assert.equal(data.get('completed'), true, 'checkbox value bound (via check)');
input.checked = false;
domEvents.dispatch(input, 'change');
equal(input.checked, false, 'checkbox value bound (via uncheck)');
equal(data.get('completed'), false, 'checkbox value bound (via uncheck)');
assert.equal(input.checked, false, 'checkbox value bound (via uncheck)');
assert.equal(data.get('completed'), false, 'checkbox value bound (via uncheck)');
});
testIfRealDocument("<select> keeps its value as <option>s change with {{#each}} (#1762)", function(){
testIfRealDocument("<select> keeps its value as <option>s change with {{#each}} (#1762)", function(assert){
var template = stache("<select value:bind='id'>{{#each values}}<option value='{{this}}'>{{this}}</option>{{/each}}</select>");

@@ -766,13 +766,13 @@ var values = new SimpleObservable( ["1","2","3","4"] );

});
stop();
var done = assert.async();
var select = frag.firstChild;
var options = select.getElementsByTagName("option");
// the value is set asynchronously
testHelpers.afterMutation(function(){
ok(options[1].selected, "value is initially selected");
testHelpers.afterMutation(function (){
assert.ok(options[1].selected, "value is initially selected");
values.set(["7","2","5","4"]);
testHelpers.afterMutation(function(){
ok(options[1].selected, "after changing options, value should still be selected");
start();
testHelpers.afterMutation(function (){
assert.ok(options[1].selected, "after changing options, value should still be selected");
done();
});

@@ -783,3 +783,3 @@ });

testIfRealDocument("<select> with undefined value selects option without value", function() {
testIfRealDocument("<select> with undefined value selects option without value", function(assert) {

@@ -796,6 +796,6 @@ var template = stache("<select value:bind='opt'><option>Loading...</option></select>");

var select = ta.childNodes.item(0);
QUnit.equal(select.selectedIndex, 0, 'Got selected index');
assert.equal(select.selectedIndex, 0, 'Got selected index');
});
testIfRealDocument('<select> two-way bound values that do not match a select option set selectedIndex to -1 (#2027)', function() {
testIfRealDocument('<select> two-way bound values that do not match a select option set selectedIndex to -1 (#2027)', function(assert) {
var renderer = stache('<select el:value:bind="key"><option value="foo">foo</option><option value="bar">bar</option></select>');

@@ -805,26 +805,25 @@ var map = new SimpleMap({ });

equal(frag.firstChild.selectedIndex, 0, 'undefined <- {($first value)}: selectedIndex = 0');
assert.equal(frag.firstChild.selectedIndex, 0, 'undefined <- {($first value)}: selectedIndex = 0');
map.attr('key', 'notfoo');
stop();
var done = assert.async();
testHelpers.afterMutation(function() {
start();
equal(frag.firstChild.selectedIndex, -1, 'notfoo: selectedIndex = -1');
testHelpers.afterMutation(function () {
assert.equal(frag.firstChild.selectedIndex, -1, 'notfoo: selectedIndex = -1');
map.attr('key', 'foo');
strictEqual(frag.firstChild.selectedIndex, 0, 'foo: selectedIndex = 0');
assert.strictEqual(frag.firstChild.selectedIndex, 0, 'foo: selectedIndex = 0');
map.attr('key', 'notbar');
stop();
testHelpers.afterMutation(function() {
start();
equal(frag.firstChild.selectedIndex, -1, 'notbar: selectedIndex = -1');
testHelpers.afterMutation(function () {
done();
assert.equal(frag.firstChild.selectedIndex, -1, 'notbar: selectedIndex = -1');
map.attr('key', 'bar');
strictEqual(frag.firstChild.selectedIndex, 1, 'bar: selectedIndex = 1');
assert.strictEqual(frag.firstChild.selectedIndex, 1, 'bar: selectedIndex = 1');
map.attr('key', 'bar');
strictEqual(frag.firstChild.selectedIndex, 1, 'bar (no change): selectedIndex = 1');
assert.strictEqual(frag.firstChild.selectedIndex, 1, 'bar (no change): selectedIndex = 1');
});

@@ -834,3 +833,3 @@ });

test("<select multiple> Multi-select empty string works(#1263)", function(){
QUnit.test("<select multiple> Multi-select empty string works(#1263)", function(assert) {

@@ -857,8 +856,8 @@ var data = new SimpleMap({

equal(frag.firstChild.getElementsByTagName("option")[0].selected, false, "The first empty value is not selected");
equal(frag.firstChild.getElementsByTagName("option")[2].selected, true, "One is selected");
assert.equal(frag.firstChild.getElementsByTagName("option")[0].selected, false, "The first empty value is not selected");
assert.equal(frag.firstChild.getElementsByTagName("option")[2].selected, true, "One is selected");
});
testIfRealDocument("<select multiple> applies initial value, when options rendered from array (#1414)", function() {
testIfRealDocument("<select multiple> applies initial value, when options rendered from array (#1414)", function(assert) {
var template = stache(

@@ -878,3 +877,3 @@ "<select values:bind='colors' multiple>" +

stop();
var done = assert.async();
var frag = template(map);

@@ -889,7 +888,7 @@

// Wait for Multiselect.set() to be called.
testHelpers.afterMutation(function(){
ok(options[0].selected, "red should be set initially");
ok(options[1].selected, "green should be set initially");
ok(!options[2].selected, "blue should not be set initially");
start();
testHelpers.afterMutation(function (){
assert.ok(options[0].selected, "red should be set initially");
assert.ok(options[1].selected, "green should be set initially");
assert.ok(!options[2].selected, "blue should not be set initially");
done();
});

@@ -901,3 +900,3 @@

test("<select> one-way bindings keep value if options are replaced - each (#1762)", function(){
QUnit.test("<select> one-way bindings keep value if options are replaced - each (#1762)", function(assert) {
var countries = [{code: 'MX', countryName:'MEXICO'},

@@ -920,17 +919,17 @@ {code: 'US', countryName:'USA'}

var select = frag.firstChild;
stop();
testHelpers.afterMutation(function(){
var done = assert.async();
testHelpers.afterMutation(function (){
data.get("countries").replace([]);
testHelpers.afterMutation(function(){
testHelpers.afterMutation(function (){
data.attr("countries").replace(countries);
equal(data.attr("countryCode"), "US", "country kept as USA");
assert.equal(data.attr("countryCode"), "US", "country kept as USA");
testHelpers.afterMutation(function(){
ok( select.getElementsByTagName("option")[1].selected, "USA still selected");
testHelpers.afterMutation(function (){
assert.ok( select.getElementsByTagName("option")[1].selected, "USA still selected");
});
start();
done();
});

@@ -942,3 +941,3 @@

testIfRealDocument("<select> value:bind select single", function() {
testIfRealDocument("<select> value:bind select single", function(assert) {

@@ -962,6 +961,6 @@ var template = stache(

equal(inputs[0].value, 'red', "default value set");
assert.equal(inputs[0].value, 'red', "default value set");
map.set("color", "green");
equal(inputs[0].value, 'green', "alternate value set");
assert.equal(inputs[0].value, 'green', "alternate value set");

@@ -975,5 +974,5 @@

equal(map.get("color"), "green", "not yet updated from input");
assert.equal(map.get("color"), "green", "not yet updated from input");
domEvents.dispatch(inputs[0], "change");
equal(map.get("color"), "red", "updated from input");
assert.equal(map.get("color"), "red", "updated from input");

@@ -985,9 +984,9 @@ canReflect.each(ta.getElementsByTagName('option'), function(opt) {

});
equal(map.get("color"), "red", "not yet updated from input");
assert.equal(map.get("color"), "red", "not yet updated from input");
domEvents.dispatch(inputs[0], "change");
equal(map.get("color"), "green", "updated from input");
assert.equal(map.get("color"), "green", "updated from input");
});
testIfRealDocument("<select> values:bind multiple select with a DefineList", function() {
testIfRealDocument("<select> values:bind multiple select with a DefineList", function(assert) {

@@ -1003,3 +1002,3 @@ var template = stache(

stop();
var done = assert.async();
var frag = template({

@@ -1021,3 +1020,3 @@ colors: list

deepEqual(list.get(), ["red"], "A DefineList value is set even if none existed");
assert.deepEqual(list.get(), ["red"], "A DefineList value is set even if none existed");

@@ -1027,3 +1026,3 @@ options[1].selected = true;

deepEqual(list.get(), ["red", "green"], "Adds items to the list");
assert.deepEqual(list.get(), ["red", "green"], "Adds items to the list");

@@ -1033,3 +1032,3 @@ options[0].selected = false;

deepEqual(list.get(), ["green"], "Removes items from the list");
assert.deepEqual(list.get(), ["green"], "Removes items from the list");

@@ -1044,7 +1043,7 @@ // Test changing observable values changes the DOM

ta.removeChild(select);
start();
done();
}, 1);
});
QUnit.test("<select> one-way bindings keep value if options are replaced (#1762)", function(){
QUnit.test("<select> one-way bindings keep value if options are replaced (#1762)", function(assert) {
var countries = [{code: 'MX', countryName:'MEXICO'},

@@ -1067,17 +1066,17 @@ {code: 'US', countryName:'USA'}

var select = frag.firstChild;
stop();
testHelpers.afterMutation(function(){
var done = assert.async();
testHelpers.afterMutation(function (){
data.get("countries").replace([]);
testHelpers.afterMutation(function(){
testHelpers.afterMutation(function (){
data.get("countries").replace(countries);
equal(data.get("countryCode"), "US", "country kept as USA");
assert.equal(data.get("countryCode"), "US", "country kept as USA");
testHelpers.afterMutation(function(){
ok( select.getElementsByTagName("option")[1].selected, "USA still selected");
testHelpers.afterMutation(function (){
assert.ok( select.getElementsByTagName("option")[1].selected, "USA still selected");
});
start();
done();
});

@@ -1089,3 +1088,3 @@

testIfRealDocument("<select> two-way bindings update to `undefined` if options are replaced - each (#1762)", function(){
testIfRealDocument("<select> two-way bindings update to `undefined` if options are replaced - each (#1762)", function(assert){
var countries = [{code: 'MX', countryName:'MEXICO'},

@@ -1107,11 +1106,11 @@ {code: 'US', countryName:'USA'}

template(data);
stop();
testHelpers.afterMutation(function(){
var done = assert.async();
testHelpers.afterMutation(function (){
data.attr("countries").replace([]);
testHelpers.afterMutation(function(){
equal(data.get("countryCode"), undefined, "countryCode set to undefined");
testHelpers.afterMutation(function (){
assert.equal(data.get("countryCode"), undefined, "countryCode set to undefined");
start();
done();
});

@@ -1123,3 +1122,3 @@

testIfRealDocument('<select> - previously non-existing select value gets selected from a list when it is added (#1762)', function() {
testIfRealDocument('<select> - previously non-existing select value gets selected from a list when it is added (#1762)', function(assert) {
// this breaks with VDOM can-stache-bindings#258 because of selectedIndex

@@ -1145,5 +1144,5 @@ var template = stache('<select el:value:bind="{person}">' +

stop();
var done = assert.async();
vm.on('person', function(ev, newVal, oldVal) {
ok(false, 'person attribute should not change');
assert.ok(false, 'person attribute should not change');
});

@@ -1153,10 +1152,10 @@

equal(vm.attr('person'), 'Brian', 'Person is still set');
assert.equal(vm.attr('person'), 'Brian', 'Person is still set');
testHelpers.afterMutation(function() {
testHelpers.afterMutation(function () {
people.push('Brian');
testHelpers.afterMutation(function() {
var options = frag.firstChild.getElementsByTagName("option");
ok(options[options.length - 1].selected, 'New child should be selected');
start();
assert.ok(options[options.length - 1].selected, 'New child should be selected');
done();
});

@@ -1166,3 +1165,3 @@ });

test("<select> select bindings respond to changes immediately or during insert using bind (#2134)", function(){
QUnit.test("<select> select bindings respond to changes immediately or during insert using bind (#2134)", function(assert) {
var countries = [{code: 'MX', countryName:'MEXICO'},

@@ -1188,6 +1187,6 @@ {code: 'US', countryName:'USA'},

stop();
testHelpers.afterMutation(function(){
start();
equal(frag.firstChild.value, "IND", "got last updated value");
var done = assert.async();
testHelpers.afterMutation(function (){
done();
assert.equal(frag.firstChild.value, "IND", "got last updated value");
});

@@ -1197,3 +1196,3 @@

testIfRealDocument("<select> two way bound select empty string null or undefined value (#2027)", function() {
testIfRealDocument("<select> two way bound select empty string null or undefined value (#2027)", function(assert) {

@@ -1222,3 +1221,3 @@ var template = stache(

});
stop();
var done = assert.async();
var frag = template(map);

@@ -1235,12 +1234,12 @@ domMutateNode.appendChild.call(this.fixture, frag);

// wait for set to be called which will change the selects
testHelpers.afterMutation(function(){
ok(!nullInputOptions[0].selected, "default (null) value set");
testHelpers.afterMutation(function (){
assert.ok(!nullInputOptions[0].selected, "default (null) value set");
// the first item is selected because "" is the value.
ok(undefinedInputOptions[0].selected, "default (undefined) value set");
ok(stringInputOptions[0].selected, "default ('') value set");
start();
assert.ok(undefinedInputOptions[0].selected, "default (undefined) value set");
assert.ok(stringInputOptions[0].selected, "default ('') value set");
done();
});
});
testIfRealDocument("<select> two way binding from a select's value to null has no selection (#2027)", function(){
testIfRealDocument("<select> two way binding from a select's value to null has no selection (#2027)", function(assert){
var template = stache("<select value:bind='key'><option value='One'>One</option></select>");

@@ -1252,13 +1251,13 @@ var map = new SimpleMap({key: null});

testHelpers.afterMutation(function(){
equal(select.selectedIndex, -1, "selectedIndex is 0 because no value exists on the map");
equal(map.get("key"), null, "The map's value property is set to the select's value");
start();
testHelpers.afterMutation(function (){
assert.equal(select.selectedIndex, -1, "selectedIndex is 0 because no value exists on the map");
assert.equal(map.get("key"), null, "The map's value property is set to the select's value");
done();
});
stop();
var done = assert.async();
});
testIfRealDocument("<select> One way binding from a select's value to a parent compute updates the parent with the select's initial value (#2027)", function(){
testIfRealDocument("<select> One way binding from a select's value to a parent compute updates the parent with the select's initial value (#2027)", function(assert){
var template = stache("<select value:to='value'><option value='One'>One</option></select>");

@@ -1270,13 +1269,13 @@ var map = new SimpleMap();

testHelpers.afterMutation(function(){
equal(select.selectedIndex, 0, "selectedIndex is 0 because no value exists on the map");
equal(map.attr("value"), "One", "The map's value property is set to the select's value");
start();
testHelpers.afterMutation(function (){
assert.equal(select.selectedIndex, 0, "selectedIndex is 0 because no value exists on the map");
assert.equal(map.attr("value"), "One", "The map's value property is set to the select's value");
done();
});
stop();
var done = assert.async();
});
testIfRealDocument("Bi-directional binding among sibling components, new syntax (#325)", function () {
testIfRealDocument("Bi-directional binding among sibling components, new syntax (#325)", function(assert) {
var groupCollapsed = console.groupCollapsed;

@@ -1333,11 +1332,11 @@ if(groupCollapsed) {

QUnit.equal(frag.childNodes[0].childNodes[0].nodeValue, '', "demoContext person is empty");
QUnit.equal(frag.childNodes[1].childNodes[0].childNodes[0].nodeValue, 'John', "source-component person is default");
QUnit.equal(frag.childNodes[2].childNodes[1].childNodes[0].nodeValue, '', "clear-button person is empty");
assert.equal(frag.childNodes[0].childNodes[0].nodeValue, '', "demoContext person is empty");
assert.equal(frag.childNodes[1].childNodes[0].childNodes[0].nodeValue, 'John', "source-component person is default");
assert.equal(frag.childNodes[2].childNodes[1].childNodes[0].nodeValue, '', "clear-button person is empty");
sourceComponentVM.person = 'Bob';
QUnit.equal(frag.childNodes[0].childNodes[0].nodeValue, 'Bob', "demoContext person set correctly");
QUnit.equal(frag.childNodes[1].childNodes[0].childNodes[0].nodeValue, 'Bob', "source-component person set correctly");
QUnit.equal(frag.childNodes[2].childNodes[1].childNodes[0].nodeValue, 'Bob', "clear-button person set correctly");
assert.equal(frag.childNodes[0].childNodes[0].nodeValue, 'Bob', "demoContext person set correctly");
assert.equal(frag.childNodes[1].childNodes[0].childNodes[0].nodeValue, 'Bob', "source-component person set correctly");
assert.equal(frag.childNodes[2].childNodes[1].childNodes[0].nodeValue, 'Bob', "clear-button person set correctly");

@@ -1349,5 +1348,5 @@ clearButtonVM.clearPerson();

// (giving the parent priority) to prevent cyclic dependencies.
QUnit.equal(frag.childNodes[0].childNodes[0].nodeValue, '', "demoContext person set correctly");
QUnit.equal(frag.childNodes[1].childNodes[0].childNodes[0].nodeValue, 'John', "source-component person set correctly");
QUnit.equal(frag.childNodes[2].childNodes[1].childNodes[0].nodeValue, '', "clear-button person set correctly");
assert.equal(frag.childNodes[0].childNodes[0].nodeValue, '', "demoContext person set correctly");
assert.equal(frag.childNodes[1].childNodes[0].childNodes[0].nodeValue, 'John', "source-component person set correctly");
assert.equal(frag.childNodes[2].childNodes[1].childNodes[0].nodeValue, '', "clear-button person set correctly");

@@ -1359,3 +1358,3 @@ if(groupCollapsed) {

testIfRealDocument("Bracket Expression with :to bindings", function () {
testIfRealDocument("Bracket Expression with :to bindings", function(assert) {
var demoContext = new DefineMap({

@@ -1385,6 +1384,6 @@ person: {

QUnit.equal(demoContext.person.name, 'Kevin', "source-component has correct name set");
assert.equal(demoContext.person.name, 'Kevin', "source-component has correct name set");
});
QUnit.test('this:to works', function() {
QUnit.test('this:to works', function(assert) {

@@ -1400,5 +1399,5 @@ var template = stache('<input this:to="this.input" />');

QUnit.equal(input, map.get("input"), "set the input");
assert.equal(input, map.get("input"), "set the input");
});
});

@@ -26,5 +26,5 @@ var QUnit = require('steal-qunit');

testHelpers.makeTests("can-stache-bindings - colon - event", function(name, doc, enableMO, testIfRealDocument){
testHelpers.makeTests("can-stache-bindings - colon - event", function(name, doc, enableMO, testIfRealDocument, testIfRealDocumentInDev){
QUnit.test("on:enter", function () {
QUnit.test("on:enter", function(assert) {
var enterEvent = require('can-event-dom-enter');

@@ -40,3 +40,3 @@ var undo = domEvents.addEvent(enterEvent);

called++;
equal(called, 1, "update called once");
assert.equal(called, 1, "update called once");
}

@@ -84,4 +84,4 @@ });

test("two bindings on one element call back the correct method", function() {
expect(2);
QUnit.test("two bindings on one element call back the correct method", function(assert) {
assert.expect(2);
var template = stache("<input on:mousemove='first()' on:click='second()'/>");

@@ -94,6 +94,6 @@

first: function() {
ok(callingFirst, "called first");
assert.ok(callingFirst, "called first");
},
second: function() {
ok(callingSecond, "called second");
assert.ok(callingSecond, "called second");
}

@@ -117,3 +117,3 @@ });

test("event behavior event bindings should be removed when the bound element is", function(assert) {
QUnit.test("event behavior event bindings should be removed when the bound element is", function(assert) {
// This test checks whether when an element

@@ -197,3 +197,3 @@ // with an event binding is removed from the

test("on:event throws an error when inside #if block (#1182)", function(assert){
QUnit.test("on:event throws an error when inside #if block (#1182)", function(assert){
var done = assert.async();

@@ -217,4 +217,4 @@ var flag = new SimpleObservable(false),

trig();
testHelpers.afterMutation(function() {
equal(clickHandlerCount, 0, "click handler not called");
testHelpers.afterMutation(function () {
assert.equal(clickHandlerCount, 0, "click handler not called");
done();

@@ -225,5 +225,5 @@ });

test('can listen to camelCase events using on:', function(){
QUnit.stop();
expect(1);
QUnit.test('can listen to camelCase events using on:', function(assert) {
var done = assert.async();
assert.expect(1);

@@ -234,4 +234,4 @@ var map = new SimpleMap({

map.someMethod = function() {
QUnit.start();
ok(true);
done();
assert.ok(true);
};

@@ -245,5 +245,5 @@

test('can listen to kebab-case events using on:', function(){
QUnit.stop();
expect(1);
QUnit.test('can listen to kebab-case events using on:', function(assert) {
var done = assert.async();
assert.expect(1);

@@ -255,4 +255,4 @@ var map = new SimpleMap({

map.someMethod = function() {
QUnit.start();
ok(true);
done();
assert.ok(true);
};

@@ -266,5 +266,5 @@

test('can bind to property on scope using :by:', function(){
stop();
expect(1);
QUnit.test('can bind to property on scope using :by:', function(assert) {
var done = assert.async();
assert.expect(1);

@@ -283,4 +283,4 @@ MockComponent.extend({

map.someMethod = function(args){
start();
equal(args[0], "Venus", "method called");
done();
assert.equal(args[0], "Venus", "method called");
};

@@ -292,5 +292,5 @@

test('can bind to entire scope using :by:this', function(){
stop();
expect(1);
QUnit.test('can bind to entire scope using :by:this', function(assert) {
var done = assert.async();
assert.expect(1);

@@ -308,4 +308,4 @@ MockComponent.extend({

map.someMethod = function(newVal){
start();
equal(newVal, "Venus", "method called");
done();
assert.equal(newVal, "Venus", "method called");
};

@@ -317,5 +317,5 @@

test('can bind to viewModel using on:vm:prop', function() {
stop();
expect(1);
QUnit.test('can bind to viewModel using on:vm:prop', function(assert) {
var done = assert.async();
assert.expect(1);

@@ -328,4 +328,4 @@ var map = new SimpleMap({

someMethod: function(newVal){
start();
equal(newVal, "Venus", "method called");
done();
assert.equal(newVal, "Venus", "method called");
}

@@ -346,5 +346,5 @@ });

test('can bind to element using on:el:prop', function() {
stop();
expect(1);
QUnit.test('can bind to element using on:el:prop', function(assert) {
var done = assert.async();
assert.expect(1);

@@ -357,4 +357,4 @@ var map = new SimpleMap({

someMethod: function(){
start();
ok(true, "method called");
done();
assert.ok(true, "method called");
}

@@ -378,4 +378,4 @@ });

test("call expressions work (#208)", function(){
expect(2);
QUnit.test("call expressions work (#208)", function(assert) {
assert.expect(2);

@@ -387,4 +387,4 @@ stache.registerHelper("addTwo", function(arg){

stache.registerHelper("helperWithArgs", function(arg){
QUnit.equal(arg, 3, "got the helper");
ok(true, "helper called");
assert.equal(arg, 3, "got the helper");
assert.ok(true, "helper called");
});

@@ -402,3 +402,3 @@

QUnit.test("events should bind when using a plain object", function () {
QUnit.test("events should bind when using a plain object", function(assert) {
var flip = false;

@@ -413,7 +413,7 @@ var template = stache("<div {{#if test}}on:foo=\"flip()\"{{/if}}>Test</div>");

domEvents.dispatch(frag.firstChild, 'foo');
QUnit.ok(flip, "Plain object method successfully called");
assert.ok(flip, "Plain object method successfully called");
});
QUnit.test("scope.arguments gives the event arguments", function(){
QUnit.test("scope.arguments gives the event arguments", function(assert) {
var template = stache("<button on:click='doSomething(scope.event, scope.arguments)'>Default Args</button>");

@@ -423,3 +423,3 @@

doSomething: function(ev, args){
equal(args[0], ev, 'default arg is ev');
assert.equal(args[0], ev, 'default arg is ev');
}

@@ -434,3 +434,3 @@ });

test("special values get called", function(assert) {
QUnit.test("special values get called", function(assert) {
assert.expect(2);

@@ -459,3 +459,3 @@ var done = assert.async();

testHelpers.afterMutation(function() {
testHelpers.afterMutation(function () {
var input = doc.getElementsByTagName("input")[0];

@@ -475,3 +475,3 @@ input.value = "bar";

QUnit.test("viewModel binding", function(){
QUnit.test("viewModel binding", function(assert) {
MockComponent.extend({

@@ -487,3 +487,3 @@ tag: "viewmodel-binding",

doSomething: function(){
ok(true, "called!");
assert.ok(true, "called!");
}

@@ -494,3 +494,3 @@ });

QUnit.test("event handlers should run in mutateQueue (#444)", function(){
QUnit.test("event handlers should run in mutateQueue (#444)", function(assert) {
var list = new DefineList([

@@ -525,6 +525,6 @@ {name: 'A'},

QUnit.ok(true, "no errors");
assert.ok(true, "no errors");
});
QUnit.test("support simple setters", function () {
QUnit.test("support simple setters", function(assert) {
var template = stache("<input on:click='this.prop = value'/>");

@@ -545,3 +545,3 @@

QUnit.equal(map.get("prop"), 'Value');
assert.equal(map.get("prop"), 'Value');

@@ -566,3 +566,3 @@

QUnit.equal(map.get("prop"), 'ELEMENT-VALUE');
assert.equal(map.get("prop"), 'ELEMENT-VALUE');

@@ -585,3 +585,3 @@ // PRIMITIVES

QUnit.equal(map.get("prop"), 3, "primitives");
assert.equal(map.get("prop"), 3, "primitives");

@@ -605,3 +605,3 @@ // setting stuff on special?

QUnit.equal(map.get("prop"), 8, "can set to result of calling a function");
assert.equal(map.get("prop"), 8, "can set to result of calling a function");

@@ -628,3 +628,3 @@ // As functions

QUnit.equal(typeof button.viewModel.get('clicked'), 'function', 'has function');
assert.equal(typeof button.viewModel.get('clicked'), 'function', 'has function');

@@ -636,6 +636,6 @@ // Dispatch click on the my-button button

QUnit.equal(map.get("clickCount"), 1, "function got called");
assert.equal(map.get("clickCount"), 1, "function got called");
});
testIfRealDocument("on:click:value:to on button (#484)", function() {
testIfRealDocument("on:click:value:to on button (#484)", function(assert) {
var template = stache("<button value='2' on:click:value:to='myProp'>Default Args</button>");

@@ -650,14 +650,14 @@

QUnit.equal(map.get('myProp'), 1, "initial value");
assert.equal(map.get('myProp'), 1, "initial value");
domEvents.dispatch(button, "click");
QUnit.equal(map.get('myProp'), 2, "set from value");
assert.equal(map.get('myProp'), 2, "set from value");
});
QUnit.test("Registering events on nullish context with :by should register an observation on the scope and properly teardown all listeners on removal", function () {
QUnit.test("Registering events on nullish context with :by should register an observation on the scope and properly teardown all listeners on removal", function(assert) {
var map = new SimpleMap({
user: null,
doSomething: function () {
QUnit.ok(true);
assert.ok(true);
}

@@ -671,17 +671,17 @@ });

domMutateNode.appendChild.call(this.fixture, fragment);
QUnit.equal(canReflect.isBound( map ), true);
assert.equal(canReflect.isBound( map ), true);
map.set("user", user);
QUnit.equal(canReflect.isBound(user), true);
assert.equal(canReflect.isBound(user), true);
domMutateNode.removeChild.call(this.fixture, div);
testHelpers.afterMutation(function(){
QUnit.equal(canReflect.isBound( map ), false);
QUnit.equal(canReflect.isBound(user), false);
testHelpers.afterMutation(function (){
assert.equal(canReflect.isBound( map ), false);
assert.equal(canReflect.isBound(user), false);
});
});
QUnit.test("Registering events on nullish context with :by should switch bindings when the context is defined and teardiwn old listener", function(){
QUnit.test("Registering events on nullish context with :by should switch bindings when the context is defined and teardiwn old listener", function(assert) {
var map = new SimpleMap({
user: null,
doSomething: function () {
QUnit.ok(true);
assert.ok(true);
}

@@ -696,18 +696,18 @@ });

stache("<div on:name:by:this.user='doSomething()'/>")(map);
QUnit.equal(canReflect.isBound( map ), true);
assert.equal(canReflect.isBound( map ), true);
map.set("user", user1);
QUnit.equal(canReflect.isBound(user1), true);
QUnit.equal(canReflect.isBound(user2), false);
assert.equal(canReflect.isBound(user1), true);
assert.equal(canReflect.isBound(user2), false);
map.set("user", user2);
QUnit.equal(canReflect.isBound(user1), false);
QUnit.equal(canReflect.isBound(user2), true);
assert.equal(canReflect.isBound(user1), false);
assert.equal(canReflect.isBound(user2), true);
});
QUnit.test('Registering events on nullish context with :by should be supported', function () {
expect(3);
QUnit.test('Registering events on nullish context with :by should be supported', function(assert) {
assert.expect(3);
var map = new SimpleMap({
user: null,
doSomething: function () {
QUnit.ok(true);
assert.ok(true);
}

@@ -729,4 +729,4 @@ });

QUnit.test('Registering events on nullish context with :by should be supported on :vm bindings', function () {
expect(2);
QUnit.test('Registering events on nullish context with :by should be supported on :vm bindings', function(assert) {
assert.expect(2);
var map = new SimpleMap({

@@ -737,3 +737,3 @@ user: null

doSomething: function(){
QUnit.ok(true);
assert.ok(true);
}

@@ -760,21 +760,35 @@ });

canTestHelpers.dev.devOnlyTest("warning when binding known DOM event name to view model (dev-only wrapper)", function() {
expect(0);
testIfRealDocument("warning when binding known DOM event name to view model (real test)", function() {
var teardown = canTestHelpers.dev.willWarn("The focus event is bound the view model for <warning-el>. Use on:el:focus to bind to the element instead.");
viewCallbacks.tag("warning-el", function(el) {
el[canSymbol.for("can.viewModel")] = new SimpleMap({});
});
testIfRealDocumentInDev("warning when binding known DOM event name to view model", function(assert) {
var teardown = canTestHelpers.dev.willWarn("The focus event is bound the view model for <warning-el>. Use on:el:focus to bind to the element instead.");
viewCallbacks.tag("warning-el", function(el) {
el[canSymbol.for("can.viewModel")] = new SimpleMap({});
});
var template = stache(
"<warning-el on:vm:click='scope.element.preventDefault()' " +
"on:el:change='scope.element.preventDefault()' " +
"on:foo='scope.element.preventDefault()' " +
"on:focus='scope.element.preventDefault()'/>"
);
var template = stache(
"<warning-el on:vm:click='scope.element.preventDefault()' " +
"on:el:change='scope.element.preventDefault()' " +
"on:foo='scope.element.preventDefault()' " +
"on:focus='scope.element.preventDefault()'/>"
);
var map = new SimpleMap({});
template(map);
QUnit.equal(teardown(), 1, 'warning shown');
var map = new SimpleMap({});
template(map);
assert.equal(teardown(), 1, 'warning shown');
});
QUnit.test("events should not create viewmodels (#540)", function(assert) {
var ta = this.fixture;
var template = stache("<div id='click-me' on:click='func()'></div>");
var frag = template({
func: function(){
assert.ok(true, "func ran");
}
});
ta.appendChild(frag);
var el = doc.getElementById("click-me");
domEvents.dispatch(el, "click");
assert.equal(el[canSymbol.for("can.viewModel")], undefined, "el does not have a viewmodel");
});

@@ -781,0 +795,0 @@

@@ -14,3 +14,3 @@ var QUnit = require('steal-qunit');

test("value:to:on:click and on:click:value:to work (#269)", function() {
QUnit.test("value:to:on:click and on:click:value:to work (#269)", function(assert) {
var template = stache(

@@ -31,3 +31,3 @@ "<input value:to:on:click='theProp'/>" +

domEvents.dispatch(bindFirstInput, "click");
QUnit.equal(map.get('theProp'), "22");
assert.equal(map.get('theProp'), "22");

@@ -38,6 +38,6 @@

domEvents.dispatch(eventFirstInput, "click");
QUnit.equal(map.get('theProp'), "23");
assert.equal(map.get('theProp'), "23");
});
QUnit.test("on:input:value:to works (#289)", function() {
QUnit.test("on:input:value:to works (#289)", function(assert) {
var scope = new SimpleMap({

@@ -59,17 +59,17 @@ myProp: ""

equal(scope.get('myProp'), 'wurld', "Got the value on the scope");
assert.equal(scope.get('myProp'), 'wurld', "Got the value on the scope");
});
QUnit.test("on:input:value:to does not initialize values (#289)", function() {
QUnit.test("on:input:value:to does not initialize values (#289)", function(assert) {
try {
stache("<input on:input:value:to='scope.vars.editing.licensePlate'/>")();
ok(true, "renderer was made without error");
assert.ok(true, "renderer was made without error");
}
catch(e) {
ok(false, e.message);
assert.ok(false, e.message);
}
});
QUnit.test("on:input:value:bind should initialize values (#457)", function() {
QUnit.test("on:input:value:bind should initialize values (#457)", function(assert) {

@@ -81,5 +81,5 @@ var frag = stache("<input on:input:value:bind='foo'/>")({

QUnit.equal(input.value, "bar", "initialized to the parent value");
assert.equal(input.value, "bar", "initialized to the parent value");
});
});

@@ -29,3 +29,3 @@ var QUnit = require('steal-qunit');

QUnit.test("on:el:click works inside {{#if}} on element with a viewModel (#279)", function() {
QUnit.test("on:el:click works inside {{#if}} on element with a viewModel (#279)", function(assert) {
var map = new SimpleMap({

@@ -37,3 +37,3 @@ });

method: function(){
ok(true, "method called");
assert.ok(true, "method called");
}

@@ -55,3 +55,3 @@ });

QUnit.test("vm:prop:to/:from/:bind work (#280)", function() {
QUnit.test("vm:prop:to/:from/:bind work (#280)", function(assert) {
var vm1 = new SimpleMap({ value: 'vm1' });

@@ -88,30 +88,30 @@ var vm2 = new SimpleMap({ value: 'vm2' });

// vm:value:to
equal(scope.attr('scope1'), 'vm1', 'vm:value:to - scope value set from vm');
assert.equal(scope.attr('scope1'), 'vm1', 'vm:value:to - scope value set from vm');
vm1.attr('value', 'vm4');
equal(scope.attr('scope1'), 'vm4', 'vm:value:to - scope updated when vm changes');
assert.equal(scope.attr('scope1'), 'vm4', 'vm:value:to - scope updated when vm changes');
scope.attr('scope1', 'scope4');
equal(vm1.attr('value'), 'vm4', 'vm:value:to - vm not updated when scope changes');
assert.equal(vm1.attr('value'), 'vm4', 'vm:value:to - vm not updated when scope changes');
// vm:value:from
equal(vm2.attr('value'), 'scope2', 'vm:value:from - vm value set from scope');
assert.equal(vm2.attr('value'), 'scope2', 'vm:value:from - vm value set from scope');
scope.attr('scope2', 'scope5');
equal(vm2.attr('value'), 'scope5', 'vm:value:from - vm updated when scope changes');
assert.equal(vm2.attr('value'), 'scope5', 'vm:value:from - vm updated when scope changes');
vm2.attr('value', 'vm5');
equal(scope.attr('scope2'), 'scope5', 'vm:value:from - scope not updated when vm changes');
assert.equal(scope.attr('scope2'), 'scope5', 'vm:value:from - scope not updated when vm changes');
// vm:value:bind
equal(vm3.attr('value'), 'scope3', 'vm:value:bind - vm value set from scope');
assert.equal(vm3.attr('value'), 'scope3', 'vm:value:bind - vm value set from scope');
scope.attr('scope3', 'scope6');
equal(vm3.attr('value'), 'scope6', 'vm:value:bind - vm updated when scope changes');
assert.equal(vm3.attr('value'), 'scope6', 'vm:value:bind - vm updated when scope changes');
vm3.attr('value', 'vm6');
equal(scope.attr('scope3'), 'vm6', 'vm:value:bind - scope updated when vm changes');
assert.equal(scope.attr('scope3'), 'vm6', 'vm:value:bind - scope updated when vm changes');
});
canTestHelpers.dev.devOnlyTest("Warning happens when changing the map that a to-parent binding points to.", function() {
canTestHelpers.dev.devOnlyTest("Warning happens when changing the map that a to-parent binding points to.", function(assert) {
var tagName = "merge-warn-test";

@@ -122,3 +122,3 @@

expect(2);
assert.expect(2);

@@ -150,10 +150,10 @@ var step1 = { "baz": "quux" };

viewModel.set("foo", overwrite);
deepEqual(data.bar.get(), { "plonk": "waldo" }, "sanity check: parent binding set (default map -> default map)");
assert.deepEqual(data.bar.get(), { "plonk": "waldo" }, "sanity check: parent binding set (default map -> default map)");
QUnit.equal(teardown(), 1, "warning shown");
assert.equal(teardown(), 1, "warning shown");
});
QUnit.test("changing a scope property calls registered stache helper's returned function", function(){
expect(1);
stop();
QUnit.test("changing a scope property calls registered stache helper's returned function", function(assert) {
assert.expect(1);
var done = assert.async();
var scope = new SimpleMap({

@@ -171,4 +171,4 @@ test: "testval"

return function(){
start();
ok(true, "helper's returned function called");
done();
assert.ok(true, "helper's returned function called");
};

@@ -185,4 +185,4 @@ });

test("one-way pass computes to components with ~", function(assert) {
expect(6);
QUnit.test("one-way pass computes to components with ~", function(assert) {
assert.expect(6);
MockComponent.extend({

@@ -197,4 +197,4 @@ tag: "foo-bar"

var vm = canViewModel(this.fixture.firstChild);
ok(vm.get("compute")[canSymbol.for('can.getValue')], "observable returned");
equal(vm.get("compute")(), "bar", "Compute has correct value");
assert.ok(vm.get("compute")[canSymbol.for('can.getValue')], "observable returned");
assert.equal(vm.get("compute")(), "bar", "Compute has correct value");

@@ -204,14 +204,14 @@ canReflect.onValue(vm.get("compute"), function() {

// the parent and once directly.
ok(true, "Change handler called");
assert.ok(true, "Change handler called");
});
baseVm.set("foo", "quux");
equal(vm.get("compute")(), "quux", "Compute updates");
assert.equal(vm.get("compute")(), "quux", "Compute updates");
vm.get("compute")("xyzzy");
equal(baseVm.get("foo"), "xyzzy", "Compute does update the other direction");
assert.equal(baseVm.get("foo"), "xyzzy", "Compute does update the other direction");
});
test("Child bindings updated before parent (#2252)", function(){
QUnit.test("Child bindings updated before parent (#2252)", function(assert) {
var template = stache("{{#eq page 'view'}}<child-binder page:from='page' title:from='title'/>{{/eq}}");

@@ -226,5 +226,5 @@ MockComponent.extend({

if(key === "page"){
equal(value, "view", "value should not be edit");
assert.equal(value, "view", "value should not be edit");
} else {
QUnit.equal(key, "title", "title was set, we are trapping right");
assert.equal(key, "title", "title was set, we are trapping right");
}

@@ -251,3 +251,3 @@

test("backtrack path in to-parent bindings (#2132)", function(){
QUnit.test("backtrack path in to-parent bindings (#2132)", function(assert) {
MockComponent.extend({

@@ -268,9 +268,9 @@ tag: "parent-export",

equal(data.get("parentValue"), "VALUE", "set on correct context");
equal(data.get("innerMap").get("parentValue"), undefined, "nothing on innerMap");
assert.equal(data.get("parentValue"), "VALUE", "set on correct context");
assert.equal(data.get("innerMap").get("parentValue"), undefined, "nothing on innerMap");
});
test("function reference to child binding (#2116)", function(){
expect(2);
QUnit.test("function reference to child binding (#2116)", function(assert) {
assert.expect(2);
var template = stache('<foo-bar vm:child:from="parent"></foo-bar>');

@@ -286,4 +286,4 @@ MockComponent.extend({

vm.attr("parent", function(){ ok(false, "should not be called"); });
equal( typeof canViewModel(frag.firstChild).attr("child"), "function", "to child binding");
vm.attr("parent", function(){ assert.ok(false, "should not be called"); });
assert.equal( typeof canViewModel(frag.firstChild).attr("child"), "function", "to child binding");

@@ -295,14 +295,14 @@ template = stache('<foo-bar vm:method:to="vmMethod"></foo-bar>');

canViewModel(frag.firstChild).attr("method",function(){
ok(false, "method should not be called");
assert.ok(false, "method should not be called");
});
equal(typeof vm.get("vmMethod"), "function", "parent export function");
assert.equal(typeof vm.get("vmMethod"), "function", "parent export function");
});
test("setter only gets called once (#2117)", function(){
expect(1);
QUnit.test("setter only gets called once (#2117)", function(assert) {
assert.expect(1);
var VM = SimpleMap.extend({
attr: function(prop, val){
if(prop === "bar") {
equal(val, "BAR");
if(arguments.length > 1 && prop === "bar") {
assert.equal(val, "BAR");
}

@@ -325,4 +325,4 @@ return SimpleMap.prototype.attr.apply(this, arguments);

test("function reference to child (#2116)", function(){
expect(2);
QUnit.test("function reference to child (#2116)", function(assert) {
assert.expect(2);
var template = stache('<foo-bar vm:child:from="parent"></foo-bar>');

@@ -333,3 +333,3 @@ MockComponent.extend({

method: function(){
ok(false, "should not be called");
assert.ok(false, "should not be called");
}

@@ -341,3 +341,3 @@ }

parent : function() {
ok(false, "should not be called");
assert.ok(false, "should not be called");
}

@@ -349,3 +349,3 @@ });

equal( typeof canViewModel(frag.firstChild).attr("child"), "function", "to child binding");
assert.equal( typeof canViewModel(frag.firstChild).attr("child"), "function", "to child binding");

@@ -357,7 +357,7 @@

ok(typeof vm.attr("vmMethod") === "function", "parent export function");
assert.ok(typeof vm.attr("vmMethod") === "function", "parent export function");
});
test("exporting methods (#2051)", function(){
expect(2);
QUnit.test("exporting methods (#2051)", function(assert) {
assert.expect(2);

@@ -369,3 +369,3 @@

method : function() {
ok(true, "foo called");
assert.ok(true, "foo called");
return 5;

@@ -379,7 +379,7 @@ }

var frag = template({});
equal( frag.lastChild.nodeValue, "5");
assert.equal( frag.lastChild.nodeValue, "5");
});
test('one way - child to parent - importing viewModel hyphenatedProp:to="test"', function(){
QUnit.test('one way - child to parent - importing viewModel hyphenatedProp:to="test"', function(assert) {
MockComponent.extend({

@@ -412,9 +412,9 @@ tag: 'import-prop-scope',

equal(importPropParentViewModel.get("test"), "Justin", "got hyphenated prop");
assert.equal(importPropParentViewModel.get("test"), "Justin", "got hyphenated prop");
equal(importPropParentViewModel.get("childComponent"), canViewModel(importPropScope), "got view model");
assert.equal(importPropParentViewModel.get("childComponent"), canViewModel(importPropScope), "got view model");
});
test('one way - child to parent - importing viewModel prop:to="test"', function() {
QUnit.test('one way - child to parent - importing viewModel prop:to="test"', function(assert) {
MockComponent.extend({

@@ -438,7 +438,7 @@ tag: 'import-prop-scope',

equal(frag.childNodes.item(0).childNodes.item(1).innerHTML,
assert.equal(frag.childNodes.item(0).childNodes.item(1).innerHTML,
'Imported: David', '{name} component scope imported into variable');
});
test('one-way - child to parent - viewModel', function(){
QUnit.test('one-way - child to parent - viewModel', function(assert) {
MockComponent.extend({

@@ -458,13 +458,13 @@ tag: "view-model-able",

equal( viewModel.get("viewModelProp"), "Mercury", "initial value kept" );
equal( map.get("scopeProp"), "Mercury", "initial value set on parent" );
assert.equal( viewModel.get("viewModelProp"), "Mercury", "initial value kept" );
assert.equal( map.get("scopeProp"), "Mercury", "initial value set on parent" );
viewModel.set("viewModelProp", "Earth");
equal(map.get("scopeProp"), "Earth", "binding from child to parent");
assert.equal(map.get("scopeProp"), "Earth", "binding from child to parent");
map.set("scopeProp", "Mars");
equal( viewModel.get("viewModelProp"), "Earth", "no binding from parent to child" );
assert.equal( viewModel.get("viewModelProp"), "Earth", "no binding from parent to child" );
});
test('one-way - child to parent - viewModel - with converters', function(){
QUnit.test('one-way - child to parent - viewModel - with converters', function(assert) {
MockComponent.extend({

@@ -493,13 +493,13 @@ tag: "view-model-able",

equal( viewModel.get("viewModelProp"), "Mercury", "initial value kept" );
equal( map.get("scopeProp"), "MERCURY", "initial value set on parent, but upper cased" );
assert.equal( viewModel.get("viewModelProp"), "Mercury", "initial value kept" );
assert.equal( map.get("scopeProp"), "MERCURY", "initial value set on parent, but upper cased" );
viewModel.set("viewModelProp", "Earth");
equal(map.get("scopeProp"), "EARTH", "binding from child to parent updated");
assert.equal(map.get("scopeProp"), "EARTH", "binding from child to parent updated");
map.set("scopeProp", "Mars");
equal( viewModel.get("viewModelProp"), "Earth", "no binding from parent to child" );
assert.equal( viewModel.get("viewModelProp"), "Earth", "no binding from parent to child" );
});
test('one-way - parent to child - viewModel', function(){
QUnit.test('one-way - parent to child - viewModel', function(assert) {

@@ -515,13 +515,13 @@

equal( viewModel.attr("viewModelProp"), "Venus", "initial value set" );
assert.equal( viewModel.attr("viewModelProp"), "Venus", "initial value set" );
viewModel.attr("viewModelProp", "Earth");
equal(map.attr("scopeProp"), "Venus", "no binding from child to parent");
assert.equal(map.attr("scopeProp"), "Venus", "no binding from child to parent");
map.attr("scopeProp", "Mars");
equal( viewModel.attr("viewModelProp"), "Mars", "binding from parent to child" );
assert.equal( viewModel.attr("viewModelProp"), "Mars", "binding from parent to child" );
});
test('two-way - reference - child:bind="scope.vars.ref" (#1700)', function(){
QUnit.test('two-way - reference - child:bind="scope.vars.ref" (#1700)', function(assert) {
var data = new SimpleMap({person: new SimpleMap({name: new SimpleMap({})}) });

@@ -556,15 +556,15 @@ MockComponent.extend({

equal( scope.peek("scope.vars.refName"), "v1", "reference scope updated");
assert.equal( scope.peek("scope.vars.refName"), "v1", "reference scope updated");
equal(refImport.get("name"), "v1", "updated ref-import");
assert.equal(refImport.get("name"), "v1", "updated ref-import");
refImport.set("name", "v2");
equal(refExport.get("name"), "v2", "updated ref-export");
assert.equal(refExport.get("name"), "v2", "updated ref-export");
equal( scope.peek("scope.vars.refName"), "v2", "actually put in refs scope");
assert.equal( scope.peek("scope.vars.refName"), "v2", "actually put in refs scope");
});
test('one-way - DOM - parent value undefined (#189)', function() {
QUnit.test('one-way - DOM - parent value undefined (#189)', function(assert) {
/* WHAT: We are testing whether, given the parent's passed property is

@@ -607,10 +607,10 @@ undefined, the child template's value is always set to undefined

equal(text(button), 'false', 'Initial value is "false"');
assert.equal(text(button), 'false', 'Initial value is "false"');
domEvents.dispatch(button, 'click');
equal(text(button), 'true', 'Value is "true" after first click');
assert.equal(text(button), 'true', 'Value is "true" after first click');
domEvents.dispatch(button, 'click');
equal(text(button), 'false', 'Value is "false" after second click');
assert.equal(text(button), 'false', 'Value is "false" after second click');
});
test("two way - viewModel (#1700)", function(){
QUnit.test("two way - viewModel (#1700)", function(assert) {

@@ -636,4 +636,4 @@ var template = stache("<div vm:viewModelProp:bind='scopeProp'/>");

equal(scopeMapSetCalled, 0, "set is not called on scope map");
equal(viewModel.get("viewModelProp"), "Hello", "initial value set" );
assert.equal(scopeMapSetCalled, 0, "set is not called on scope map");
assert.equal(viewModel.get("viewModelProp"), "Hello", "initial value set" );

@@ -652,13 +652,13 @@ viewModel = canViewModel(frag.firstChild);

viewModel.set("viewModelProp", "HELLO");
equal(map.get("scopeProp"), "HELLO", "binding from child to parent");
equal(scopeMapSetCalled, 1, "set is called on scope map");
equal(viewModelSetCalled, 2, "set is called viewModel");
assert.equal(map.get("scopeProp"), "HELLO", "binding from child to parent");
assert.equal(scopeMapSetCalled, 1, "set is called on scope map");
assert.equal(viewModelSetCalled, 2, "set is called viewModel");
map.set("scopeProp", "WORLD");
equal(viewModel.get("viewModelProp"), "WORLD", "binding from parent to child" );
equal(scopeMapSetCalled, 1, "can.setKey is not called again on scope map");
equal(viewModelSetCalled, 3, "set is called again on viewModel");
assert.equal(viewModel.get("viewModelProp"), "WORLD", "binding from parent to child" );
assert.equal(scopeMapSetCalled, 1, "can.setKey is not called again on scope map");
assert.equal(viewModelSetCalled, 3, "set is called again on viewModel");
});
test("standard attributes should not set viewModel props", function(){
QUnit.test("standard attributes should not set viewModel props", function(assert) {
MockComponent.extend({

@@ -677,7 +677,7 @@ tag: "test-elem",

equal(vm.get('foo'), undefined);
assert.equal(vm.get('foo'), undefined);
});
test("set string on the viewModel", function(){
expect(2);
QUnit.test("set string on the viewModel", function(assert) {
assert.expect(2);
var ViewModel = DefineMap.extend({

@@ -687,3 +687,3 @@ foo: {

set: function(val){
equal(val, "bar");
assert.equal(val, "bar");
}

@@ -694,3 +694,3 @@ },

set: function(val){
equal(val, "qux");
assert.equal(val, "qux");
}

@@ -763,4 +763,4 @@ }

canTestHelpers.dev.devOnlyTest("warning displayed when using @", function(){
expect(3);
canTestHelpers.dev.devOnlyTest("warning displayed when using @", function(assert){
assert.expect(3);
var teardown = canTestHelpers.dev.willWarn("myTemplate.stache:1: functions are no longer called by default so @ is unnecessary in '@scope.vars.refKey'.");

@@ -772,3 +772,3 @@

method : function() {
ok(true, "foo called");
assert.ok(true, "foo called");
return 5;

@@ -783,8 +783,8 @@ }

var frag = template({});
equal( frag.lastChild.nodeValue, "5");
equal(teardown(), 2, "warnings displayed for read and write");
assert.equal( frag.lastChild.nodeValue, "5");
assert.equal(teardown(), 2, "warnings displayed for read and write");
});
QUnit.test("bindings.viewModel makeViewModel gets passed the binding state", function(){
QUnit.test("bindings.viewModel makeViewModel gets passed the binding state", function(assert) {

@@ -797,4 +797,4 @@ var element = document.createElement("bindings-viewmodel");

}, function(data, hasDataBinding, bindingState){
QUnit.equal(bindingState.isSettingOnViewModel,true, "isSettingOnViewModel called with correct value");
QUnit.ok(!bindingState.isSettingViewModel, "isSettingOnViewModel called with correct value");
assert.equal(bindingState.isSettingOnViewModel,true, "isSettingOnViewModel called with correct value");
assert.ok(!bindingState.isSettingViewModel, "isSettingOnViewModel called with correct value");
}, {});

@@ -808,4 +808,4 @@

}, function(data, hasDataBinding, bindingState){
QUnit.ok(!bindingState.isSettingOnViewModel, "isSettingOnViewModel called with correct value");
QUnit.ok(bindingState.isSettingViewModel, "isSettingOnViewModel called with correct value");
assert.ok(!bindingState.isSettingOnViewModel, "isSettingOnViewModel called with correct value");
assert.ok(bindingState.isSettingViewModel, "isSettingOnViewModel called with correct value");
}, {});

@@ -815,3 +815,3 @@

QUnit.test("double parent update", function() {
QUnit.test("double parent update", function(assert) {
var parentVM = new SimpleMap({

@@ -846,6 +846,6 @@ parentValue: ""

QUnit.equal(parentVM.get("parentValue"), "gc");
assert.equal(parentVM.get("parentValue"), "gc");
});
QUnit.test("scope.event should be available", function() {
QUnit.test("scope.event should be available", function(assert) {
var vm = new SimpleMap({});

@@ -862,5 +862,5 @@ MockComponent.extend({

doSomething: function(events, argums, args){
QUnit.equal(events.type , "event", "got an event");
QUnit.equal(argums.length, 2, "two arguments");
QUnit.equal(args.length, 3, "3 args");
assert.equal(events.type , "event", "got an event");
assert.equal(argums.length, 2, "two arguments");
assert.equal(args.length, 3, "3 args");
}

@@ -871,3 +871,3 @@ });

QUnit.test("nested props with two way binding", function() {
QUnit.test("nested props with two way binding", function(assert) {
var nestedValue = new SimpleMap({

@@ -901,4 +901,4 @@ first: 'Matt'

QUnit.equal(parentVM.get('name'), 'updated', 'parent vm has correct value');
QUnit.equal(nestedValue.get('first'), 'updated', 'child vm has correct value');
assert.equal(parentVM.get('name'), 'updated', 'parent vm has correct value');
assert.equal(nestedValue.get('first'), 'updated', 'child vm has correct value');

@@ -908,5 +908,36 @@ childInput.value = 'child-updated';

QUnit.equal(parentVM.get('name'), 'child-updated', 'parent vm has correct value');
QUnit.equal(nestedValue.get('first'), 'child-updated', 'child vm has correct value');
assert.equal(parentVM.get('name'), 'child-updated', 'parent vm has correct value');
assert.equal(nestedValue.get('first'), 'child-updated', 'child vm has correct value');
});
canTestHelpers.dev.devOnlyTest("warn when changing the value of a sticky binding child-side (initializing view model)", function(assert) {
assert.expect(2);
var teardown = canTestHelpers.dev.willWarn(
"can-bind: The child of the sticky two-way binding <my-child name.first:bind=\"name\"> is changing or converting its value when set. " +
"Conversions should only be done on the binding parent to preserve synchronization. " +
"See https://canjs.com/doc/can-stache-bindings.html#StickyBindings for more about sticky bindings",
function(text, match) {
if(match) {
assert.ok(true, "Correct warning generated");
}
}
);
var childVM = new SimpleMap({
name: {
first: "Matt"
}
});
MockComponent.extend({
tag: "my-child",
viewModel: childVM,
template: stache('<input value:bind="name.first" />')
});
var parentVM = new SimpleMap({
name: 'Justin'
});
stache('<my-child name.first:bind="name" /><input value:bind="name" />')(parentVM);
assert.equal(teardown(), 1, "Warning generated only once");
});
});

@@ -7,6 +7,8 @@ var globals = require('can-globals');

var makeDocument = require('can-vdom/make-document/make-document');
var canTestHelpers = require('can-test-helpers');
var helpers = {
makeQUnitModule: function(name, doc, enableMO){
QUnit.module(name, {
setup: function() {
beforeEach: function() {

@@ -25,3 +27,3 @@ globals.setKeyValue('document', doc);

},
teardown: function(){
afterEach: function(assert){
if(doc !== document) {

@@ -31,3 +33,3 @@ doc.body.removeChild(this.fixture);

stop();
var done = assert.async();
helpers.afterMutation(function() {

@@ -44,3 +46,3 @@

start();
done();
});

@@ -63,8 +65,10 @@ }

makeTests: function(name, makeTest) {
var noop = function(){};
helpers.makeQUnitModule(name+" - dom", document, true);
makeTest(name+" - dom", document, true, QUnit.test);
makeTest(name+" - dom", document, true, QUnit.test, noop);
makeTest(name+" - dom - dev only", document, true, noop, canTestHelpers.dev.devOnlyTest);
var doc = makeDocument();
helpers.makeQUnitModule(name+" - vdom", doc, false);
makeTest(name+" - vdom", doc, false, function(){});
makeTest(name+" - vdom", doc, false, noop, noop);
},

@@ -71,0 +75,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc