Skip to content

Commit

Permalink
Handle false value in function directives
Browse files Browse the repository at this point in the history
  • Loading branch information
pure committed Jul 16, 2011
1 parent 3312f81 commit 317809a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
12 changes: 8 additions & 4 deletions libs/pure.js
Expand Up @@ -7,7 +7,7 @@
Copyright (c) 2011 Michael Cvilic - BeeBole.com
Thanks to Rog Peppe for the functional JS jump
revision: 2.71
revision: 2.72
*/

var $p, pure = $p = function(){
Expand Down Expand Up @@ -182,9 +182,13 @@ $p.core = function(sel, ctxt, plugins){

// parse a data selector and return a function that
// can traverse the data accordingly, given a context.
function dataselectfn(sel){
if(typeof(sel) === 'function'){
return sel;
function dataselectfn (sel){
if( typeof(sel) === 'function' ){
//handle false values in function directive
return function ( ctxt ){
var r = sel.call( ctxt.item || ctxt.context || ctxt, ctxt );
return !r && r !== 0 ? '' : r;
};
}
//check for a valid js variable name with hyphen(for properties only), $, _ and :
var m = sel.match(/^[a-zA-Z\$_\@][\w\$:-]*(\.[\w\$:-]*[^\.])*$/);
Expand Down
32 changes: 16 additions & 16 deletions libs/pure_min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 317809a

Please sign in to comment.