Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

improve the way undefined is used in a few places #620

Closed
wants to merge 2 commits into from

2 participants

@vikstrous

These changes should have no effect on the logic and make the code slightly smaller and simpler. I couldn't run the tests locally. Please test.

Also, any idea why I can't run the tests?

$ rake test
script/test
Can't open 'test/runner.coffee'
rake aborted!
Command failed with status (255): [script/test...]

Tasks: TOP => test
(See full trace by running task with --trace)
$ ls test/runner.coffee 
test/runner.coffee
@mislav
Collaborator

Thanks! Pulled.

You need phantomjs to run the tests. On Max OS X: brew install phantomjs

@mislav mislav closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 20, 2012
  1. @vikstrous
Commits on Oct 21, 2012
  1. @vikstrous

    missing brackets

    vikstrous authored
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 6 deletions.
  1. +3 −6 src/zepto.js
View
9 src/zepto.js
@@ -54,7 +54,7 @@ var Zepto = (function() {
function isArray(value) { return value instanceof Array }
function likeArray(obj) { return typeof obj.length == 'number' }
- function compact(array) { return filter.call(array, function(item){ return item !== undefined && item !== null }) }
+ function compact(array) { return filter.call(array, function(item){ return item != null }) } /* Note: null and undefined are == equal */
function flatten(array) { return array.length > 0 ? $.fn.concat.apply([], array) : array }
camelize = function(str){ return str.replace(/-+(.)?/g, function(match, chr){ return chr ? chr.toUpperCase() : '' }) }
function dasherize(str) {
@@ -534,7 +534,7 @@ var Zepto = (function() {
},
prop: function(name, value){
return (value === undefined) ?
- (this[0] ? this[0][name] : undefined) :
+ (this[0] && this[0][name]) :
this.each(function(idx){
this[name] = funcArg(this, value, idx, this[name])
})
@@ -564,10 +564,7 @@ var Zepto = (function() {
},
css: function(property, value){
if (arguments.length < 2 && typeof property == 'string')
- return (
- this.length == 0
- ? undefined
- : this[0].style[camelize(property)] || getComputedStyle(this[0], '').getPropertyValue(property))
+ return this[0] && (this[0].style[camelize(property)] || getComputedStyle(this[0], '').getPropertyValue(property))
var css = ''
for (key in property)
Something went wrong with that request. Please try again.