From 1ff67aa5bd14663d606b30d41ba24faa8066ce86 Mon Sep 17 00:00:00 2001 From: Mark Nadig Date: Thu, 30 Apr 2015 15:46:33 -0600 Subject: [PATCH 01/26] Update using-examples.md fix link to canjs_require --- guides/using-examples.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/using-examples.md b/guides/using-examples.md index d95ce8dacd0..b3d41900d10 100644 --- a/guides/using-examples.md +++ b/guides/using-examples.md @@ -107,7 +107,7 @@ With [Grunt](http://gruntjs.com/) as a build tool your `Gruntfile.js` to create ## Bower + RequireJS -A fairly common setup is using CanJS with RequireJS and [Bower](http://bower.io/) as the package manager which is described in the following section. For a working example have a look at the [RequireJS + CanJS TodoMVC example](http://todomvc.com/labs/dependency-examples/canjs_require/). +A fairly common setup is using CanJS with RequireJS and [Bower](http://bower.io/) as the package manager which is described in the following section. For a working example have a look at the [RequireJS + CanJS TodoMVC example](http://todomvc.com/examples/canjs_require/). If you haven't yet, initialize a `bower.json` in your project folder by running From a5e0b5938cb23a3bd619cf4308b668c679e8a6bf Mon Sep 17 00:00:00 2001 From: Marshall Thompson Date: Thu, 30 Apr 2015 21:09:24 -0600 Subject: [PATCH 02/26] Fix example widget name The text refers to a my-widget component, but the code examples show a hello-world component. I've changed the text to match the code. --- component/leakscope.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/component/leakscope.md b/component/leakscope.md index 373c7d2f8da..55be043c488 100644 --- a/component/leakscope.md +++ b/component/leakscope.md @@ -26,7 +26,7 @@ user content can read the component's view model. Lets define what __outer scope__, __component's template__ and __user content__ mean. -If I have component `` in a template like: +If I have a `` component in a template like: ``` {{#data}} @@ -38,7 +38,7 @@ The __outer scope__ of `` has `data` as its context. The __user co `` is the template between its tags. In this case, the __user content__ is `{{subject}}`. -Finally, if `` is defined like: +Finally, if `` is defined like: ``` can.Component.extend({ From ada39ce557843870e41aebcd334ebf145eef60d9 Mon Sep 17 00:00:00 2001 From: Manuel Mujica Date: Fri, 1 May 2015 17:16:38 -0300 Subject: [PATCH 03/26] Make findAll reject on non-array data property. Closes #1662. --- model/model.js | 14 +++++++------- model/model_test.js | 30 ++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/model/model.js b/model/model.js index db4d3963c96..6869a032422 100644 --- a/model/model.js +++ b/model/model.js @@ -173,7 +173,7 @@ steal('can/util', 'can/map', 'can/list', function (can) { raw = raw.data; } - if (typeof raw === 'undefined') { + if (typeof raw === 'undefined' || !can.isArray(raw)) { throw new Error('Could not get any raw data while converting using .models'); } @@ -331,15 +331,15 @@ steal('can/util', 'can/map', 'can/list', function (can) { }; }, // ## createURLFromResource - // For each of the names (create, update, destroy, findOne, and findAll) use the + // For each of the names (create, update, destroy, findOne, and findAll) use the // URL provided by the `resource` property. For example: - // + // // ToDo = can.Model.extend({ // resource: "/todos" // }, {}); - // + // // Will create a can.Model that is identical to: - // + // // ToDo = can.Model.extend({ // findAll: "GET /todos", // findOne: "GET /todos/{id}", @@ -347,7 +347,7 @@ steal('can/util', 'can/map', 'can/list', function (can) { // update: "PUT /todos/{id}", // destroy: "DELETE /todos/{id}" // },{}); - // + // // - `model`: the can.Model that has the resource property // - `method`: a property from the ajaxMethod object createURLFromResource = function(model, name) { @@ -642,7 +642,7 @@ steal('can/util', 'can/map', 'can/list', function (can) { can.dispatch.call(constructor, funcName, [this]); }; }); - + // # can.Model.List // Model Lists are just like `Map.List`s except that when their items are diff --git a/model/model_test.js b/model/model_test.js index d8b5144e83c..9736aa0574e 100644 --- a/model/model_test.js +++ b/model/model_test.js @@ -76,6 +76,7 @@ steal("can/model", 'can/map/attributes', "can/test", "can/util/fixture", "steal- start(); }); }); + asyncTest('findAll deferred reject', function () { // This test is automatically paused function rejectDeferred(df) { @@ -1436,6 +1437,35 @@ steal("can/model", 'can/map/attributes', "can/test", "can/util/fixture", "steal- }); + test("findAll rejects when parseModels returns non-array data #1662", function(){ + can.fixture("/mymodels", function () { + return { + status: 'success', + message: '' + }; + }); + + var MyModel = can.Model.extend({ + findAll: "/mymodels", + parseModels: function(raw) { + raw.data = undefined; + return raw; + }, + }, {}); + + stop(); + + MyModel.findAll({}) + .then(function(){ + ok(false, 'This should not succeed'); + start(); + }, function(err){ + ok(err instanceof Error, 'Got an error'); + equal(err.message, 'Could not get any raw data while converting using .models'); + start(); + }); + }); + test("Nested lists", function(){ var Teacher = can.Model.extend({}); var teacher = new Teacher(); From 684f682be8a88c4eb1f5bbb62ae8fd925b2e6382 Mon Sep 17 00:00:00 2001 From: Chris Gomez Date: Tue, 28 Apr 2015 11:14:17 -0400 Subject: [PATCH 04/26] only require one argument to save with setter --- map/define/define.js | 4 +-- map/define/define_test.js | 59 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/map/define/define.js b/map/define/define.js index d4651822fb4..e483e970eb0 100644 --- a/map/define/define.js +++ b/map/define/define.js @@ -155,7 +155,7 @@ steal('can/util', 'can/observe', function (can) { if (getter) { // if there's a getter we don't call old set // instead we call the getter's compute with the new value - if(setValue !== undefined && !setterCalled && setter.length >= 2) { + if(setValue !== undefined && !setterCalled && setter.length >= 1) { this[prop](setValue); } @@ -163,7 +163,7 @@ steal('can/util', 'can/observe', function (can) { return; } // if it took a setter and returned nothing, don't set the value - else if (setValue === undefined && !setterCalled && setter.length >= 2) { + else if (setValue === undefined && !setterCalled && setter.length >= 1) { //!steal-remove-start asyncTimer = setTimeout(function () { can.dev.warn('can/map/setter.js: Setter "' + prop + '" did not return a value or call the setter callback.'); diff --git a/map/define/define_test.js b/map/define/define_test.js index c1b47db97e9..54478a4ceeb 100644 --- a/map/define/define_test.js +++ b/map/define/define_test.js @@ -908,4 +908,63 @@ steal("can/map/define", "can/route", "can/test", "steal-qunit", function () { equal(personEvents,2); }); + + test('Can read a defined property with a set/get method (#1648)', function () { + // Problem: "get" is not passed the correct "lastSetVal" + // Problem: Cannot read the value of "foo" + + var Map = can.Map.extend({ + define: { + foo: { + value: '', + set: function (setVal) { + return setVal; + }, + get: function (lastSetVal) { + return lastSetVal; + } + } + } + }); + + var map = new Map(); + + equal(map.attr('foo'), '', 'Calling .attr(\'foo\') returned the correct value'); + + map.attr('foo', 'baz'); + + equal(map.attr('foo'), 'baz', 'Calling .attr(\'foo\') returned the correct value'); + }); + + test('Can bind to a defined property with a set/get method (#1648)', 3, function () { + // Problem: "get" is not called before and after the "set" + // Problem: Function bound to "foo" is not called + // Problem: Cannot read the value of "foo" + + var Map = can.Map.extend({ + define: { + foo: { + value: '', + set: function (setVal) { + return setVal; + }, + get: function (lastSetVal) { + return lastSetVal; + } + } + } + }); + + var map = new Map(); + + map.bind('foo', function () { + ok(true, 'Bound function is called'); + }); + + equal(map.attr('foo'), '', 'Calling .attr(\'foo\') returned the correct value'); + + map.attr('foo', 'baz'); + + equal(map.attr('foo'), 'baz', 'Calling .attr(\'foo\') returned the correct value'); + }); }); From 29c2dd503d96c7db62ca2ddf7a1ee6d92f197c94 Mon Sep 17 00:00:00 2001 From: Brian Moschel Date: Sat, 2 May 2015 03:07:00 -0500 Subject: [PATCH 05/26] fixes #1115, walking up scope should continue if the scope is a primitive --- view/scope/scope.js | 4 +++- view/stache/stache_test.js | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/view/scope/scope.js b/view/scope/scope.js index d0d75daf61d..83691111069 100644 --- a/view/scope/scope.js +++ b/view/scope/scope.js @@ -255,7 +255,9 @@ steal( while (scope) { context = scope._context; - if (context !== null) { + if (context !== null && + // if its a primitive type, keep looking up the scope, since there won't be any properties + (typeof context === "object" || typeof context === "function") ) { var data = can.compute.read(context, names, can.simpleExtend({ /* Store found observable, incase we want to set it as the rootObserve. */ foundObservable: function (observe, nameIndex) { diff --git a/view/stache/stache_test.js b/view/stache/stache_test.js index 076a02a70f7..94d46712f9d 100644 --- a/view/stache/stache_test.js +++ b/view/stache/stache_test.js @@ -3930,4 +3930,21 @@ steal("can/view/stache", "can/view", "can/test","can/view/mustache/spec/specs"," equal(frag.childNodes.length, 1, "only the placeholder textnode"); }); + + + test('template with a block section and nested if doesnt render correctly', function() { + var myMap = new can.Map({ + bar: true + }); + + var frag = can.stache( + "{{#bar}}
{{#if foo}}My Meals{{else}}My Order{{/if}}
{{/bar}}" + )(myMap); + + can.append(can.$('#qunit-fixture'), frag); + equal(can.$('#qunit-fixture div')[0].innerHTML, 'My Order', 'shows else case'); + myMap.attr('foo', true); + equal(can.$('#qunit-fixture div')[0].innerHTML, 'My Meals', 'shows if case'); + + }); }); From 6d426dc8784e1ba10ab50e44c1f855ab521f5aa8 Mon Sep 17 00:00:00 2001 From: Mark Nadig Date: Mon, 4 May 2015 16:39:02 -0600 Subject: [PATCH 06/26] Update for steal Direct user to Can2.2/Steal blog post for current info. --- guides/using-production.md | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/guides/using-production.md b/guides/using-production.md index 575e41eb838..dd7b924ac11 100644 --- a/guides/using-production.md +++ b/guides/using-production.md @@ -44,9 +44,4 @@ Read up in the [can-compile + RequireJS](https://github.com/daffl/can-compile#lo ## Building with StealJS -When using [using-steal CanJS with StealJS] with the generated application you can simply run - -> ./js app/scripts/build.js - -In your JavaScriptMVC folder. This will create `app/production.js` and `app/production.css` which will be loaded when -referencing `steal.production.js` in `app/index.html` (instead of `steal.js` itself). +See [using CanJS 2.2 with StealJS](http://blog.bitovi.com/using-canjs-2-2-with-stealjs/) for tips on building Can with StealJS. From a4424563d6ba6fb0c1253412514b197219f3beb4 Mon Sep 17 00:00:00 2001 From: Mark Nadig Date: Mon, 4 May 2015 16:44:06 -0600 Subject: [PATCH 07/26] Update for steal Direct user to CanJS 2.2 with StealJS blog post for instructions. Removed link to JavascriptMVC. --- guides/using-loading.md | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/guides/using-loading.md b/guides/using-loading.md index 1090f97413f..a6bb16942ac 100644 --- a/guides/using-loading.md +++ b/guides/using-loading.md @@ -243,21 +243,4 @@ With RequireJS and Zepto, it loks like this: ## StealJS -StealJS is the dependency manager that comes with [JavaScriptMVC](http://javascriptmvc.com) and that is natively used by CanJS. -Since JavaScriptMVC comes with CanJS and Steal, the easiest way to use them together is by [downloading JavaScriptMVC](http://javascriptmvc.com/dist/javascriptmvc-3.3.zip). You can also use the `steal/` folder from the CanJS download or Bower package. - -With the JavaScriptMVC download, in the main folder, you can simply run the application generator: - -> ./js jmvc/generate/app app - -In `app/app.js` you should see something like: - - steal( - './app.less', - './models/fixtures/fixtures.js', - function(){ - - }) - -This file will be loaded when opening `app/index.html` and you are ready to use CanJS with StealJS and make [using-production production builds]. -For more information follow up in the [JavaScriptMVC documentation](http://javascriptmvc.com/docs). +See [using CanJS 2.2 with StealJS](http://blog.bitovi.com/using-canjs-2-2-with-stealjs/) for instructions on loading Can with the latest StealJS. From a50a92aff6d330c034241e4bd11d35fcf163f802 Mon Sep 17 00:00:00 2001 From: Marshall Thompson Date: Fri, 8 May 2015 21:35:27 -0600 Subject: [PATCH 08/26] Added missing word "DatePicker" --- view/doc/tag.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/doc/tag.md b/view/doc/tag.md index d63b7f3d11b..f01acdcc45f 100644 --- a/view/doc/tag.md +++ b/view/doc/tag.md @@ -26,7 +26,7 @@ render `tagData.subtemplate` and the result is inserted as the childNodes of `el `can.view.tag` is a low-level way to add custom behavior to custom elements. Often, you want to do this with [can.Component]. However, `can.view.tag` is useful for when [can.Component] might be considered overkill. For example, the -following creates a [jQueryUI](http://api.jqueryui.com/datepicker/) everytime a +following creates a [jQueryUI DatePicker](http://api.jqueryui.com/datepicker/) everytime a `` element is found: can.view.tag("jqui-datepicker", function(el, tagData){ From b25e65aa7e53836e1048bef033e0b42868370978 Mon Sep 17 00:00:00 2001 From: Brian Moschel Date: Sat, 2 May 2015 23:03:40 -0500 Subject: [PATCH 09/26] Fixes tooltip demo --- map/validations/doc/validations.html | 2 +- package.json | 2 ++ view/doc/dynamic_tooltip.html | 4 ++-- view/doc/fade_in_when.html | 2 +- view/doc/tooltip.html | 4 ++-- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/map/validations/doc/validations.html b/map/validations/doc/validations.html index b8aa5a47a68..1c986783d07 100644 --- a/map/validations/doc/validations.html +++ b/map/validations/doc/validations.html @@ -23,7 +23,7 @@

Observe Validations Demo

+ - +
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<% modules.forEach(function(module) { %> -<% if(!module.isDefault) { %> - -<% } %> -<% }); %> +<% modules.forEach(function(module) { %><% if(!module.isDefault) { %><% } %><% }); %> -
    -
  • {{name}}
  • -
+### Getting more specific -Rendered with: - - document.body.appendChild( - can.stache(template,{ person: { name: 'Austin' } }); - -Retrieve the person data back with: - - $("#person").data("person") +By passing a key name as the second argument to the data helper, you can specify which data is used: `{{data name key}}`. +JS Bin \ No newline at end of file From cf5391b398962e2ad64770ac6a6690b8de5f8e5d Mon Sep 17 00:00:00 2001 From: Justin Meyer Date: Sun, 17 May 2015 20:05:01 -0500 Subject: [PATCH 24/26] fixes mootools proxy method so it works with comptues --- util/mootools/mootools.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util/mootools/mootools.js b/util/mootools/mootools.js index e09899aa2cc..c14252207ed 100644 --- a/util/mootools/mootools.js +++ b/util/mootools/mootools.js @@ -103,11 +103,12 @@ steal('can/util/can.js', 'can/util/attr', 'mootools', 'can/event', 'can/util/fra return Object.keys(object) .length === 0; }; + var k = function(){}; // Map function helpers. can.proxy = function () { var args = can.makeArray(arguments), func = args.shift(); - return func.bind.apply(func, args); + return k.bind.apply(func, args); }; can.isFunction = function (f) { return typeOf(f) === 'function'; From 6e42473bf0aa23814a311f5736cf0fae177c87e8 Mon Sep 17 00:00:00 2001 From: Justin Meyer Date: Sun, 17 May 2015 20:49:24 -0500 Subject: [PATCH 25/26] removing a compatability test --- test/pluginified/2.0.5.test.js | 36 ---------------------------------- 1 file changed, 36 deletions(-) diff --git a/test/pluginified/2.0.5.test.js b/test/pluginified/2.0.5.test.js index 765d60f6cef..6658352f60f 100644 --- a/test/pluginified/2.0.5.test.js +++ b/test/pluginified/2.0.5.test.js @@ -10331,42 +10331,6 @@ var __m48 = (function () { }); - test("directly nested live sections unbind without needing the element to be removed", function () { - var template = can.view.mustache( - "
" + - "{{#items}}" + - "

first

" + - "{{#visible}}{{/visible}}" + - "

second

" + - "{{/items}}" + - "
"); - - var data = new can.Map({ - items: [{ - visible: true - }] - }); - - function handler(eventType) { - can.Map.prototype.unbind.apply(this, arguments); - if (eventType === "visible") { - start(); - ok(true, "unbound visible") - } - } - - data.attr("items.0") - .unbind = handler; - - template(data); - - data.attr("items", [{ - visible: true - }]); - - stop(); - }) - test("direct live section", function () { var template = can.view.mustache("{{#if visible}}