diff --git a/util/can.js b/util/can.js index 642ab3c31c7..6bcfea52a02 100644 --- a/util/can.js +++ b/util/can.js @@ -40,7 +40,19 @@ steal(function () { can.last = function(arr){ return arr && arr[arr.length - 1]; }; - + var protoBind = Function.prototype.bind; + if(protoBind) { + can.proxy = function(fn, context){ + return protoBind.apply(fn, context); + }; + } else { + can.proxy = function (fn, context) { + return function () { + return fn.apply(context, arguments); + }; + }; + } + can.frag = function(item){ var frag; diff --git a/util/jquery/jquery.js b/util/jquery/jquery.js index 1efef14d3f0..54f134ec434 100644 --- a/util/jquery/jquery.js +++ b/util/jquery/jquery.js @@ -95,11 +95,7 @@ steal('jquery', 'can/util/can.js', 'can/util/attr', "can/event", 'can/util/array } return this; }, - proxy: function (fn, context) { - return function () { - return fn.apply(context, arguments); - }; - }, + proxy: can.proxy, attr: attr }); // Wrap binding functions. diff --git a/util/mootools/mootools.js b/util/mootools/mootools.js index c14252207ed..ae3d32d6f1b 100644 --- a/util/mootools/mootools.js +++ b/util/mootools/mootools.js @@ -103,13 +103,6 @@ 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 k.bind.apply(func, args); - }; can.isFunction = function (f) { return typeOf(f) === 'function'; }; diff --git a/util/zepto/zepto.js b/util/zepto/zepto.js index 1bd9c07a4f5..3c3607a0e2b 100644 --- a/util/zepto/zepto.js +++ b/util/zepto/zepto.js @@ -180,12 +180,6 @@ steal('can/util/can.js', 'can/util/attr', 'can/event', 'zepto', 'can/util/object return ret; }; - can.proxy = function (f, ctx) { - return function () { - return f.apply(ctx, arguments); - }; - }; - // Make ajax. var XHR = $.ajaxSettings.xhr; $.ajaxSettings.xhr = function () { diff --git a/view/stache/doc/helpers/data.md b/view/stache/doc/helpers/data.md index 0d22b0f225f..35eabce1691 100644 --- a/view/stache/doc/helpers/data.md +++ b/view/stache/doc/helpers/data.md @@ -1,6 +1,6 @@ @function can.stache.helpers.data {{data name}} @parent can.stache.htags 7 -@signature `{{data name}}` +@signature `{{data name[ key]}}` Adds the current [can.stache.context context] to the element's [can.data]. @@ -12,23 +12,15 @@ context. ## Use -It is common for you to want some data in the template to be available +It is common to want some data in the template to be available on an element. `{{data name}}` allows you to save the context so it can later be retrieved by [can.data] or -`$.fn.data`. For example, +`$.fn.data`. -The template: +JS Bin - +### 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