Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

improve the way undefined is used in a few places

  • Loading branch information...
commit bc7fe4c589cf2498f35543f181783b1f0ed57284 1 parent dea8af9
Viktor Stanchev authored

Showing 1 changed file with 3 additions and 5 deletions. Show diff stats Hide diff stats

  1. +3 5 src/zepto.js
8 src/zepto.js
@@ -54,7 +54,7 @@ var Zepto = (function() {
54 54 function isArray(value) { return value instanceof Array }
55 55 function likeArray(obj) { return typeof obj.length == 'number' }
56 56
57   - function compact(array) { return filter.call(array, function(item){ return item !== undefined && item !== null }) }
  57 + function compact(array) { return filter.call(array, function(item){ return item != null }) } /* Note: null and undefined are == equal */
58 58 function flatten(array) { return array.length > 0 ? $.fn.concat.apply([], array) : array }
59 59 camelize = function(str){ return str.replace(/-+(.)?/g, function(match, chr){ return chr ? chr.toUpperCase() : '' }) }
60 60 function dasherize(str) {
@@ -534,7 +534,7 @@ var Zepto = (function() {
534 534 },
535 535 prop: function(name, value){
536 536 return (value === undefined) ?
537   - (this[0] ? this[0][name] : undefined) :
  537 + (this[0] && this[0][name]) :
538 538 this.each(function(idx){
539 539 this[name] = funcArg(this, value, idx, this[name])
540 540 })
@@ -565,9 +565,7 @@ var Zepto = (function() {
565 565 css: function(property, value){
566 566 if (arguments.length < 2 && typeof property == 'string')
567 567 return (
568   - this.length == 0
569   - ? undefined
570   - : this[0].style[camelize(property)] || getComputedStyle(this[0], '').getPropertyValue(property))
  568 + this[0] && this[0].style[camelize(property)] || getComputedStyle(this[0], '').getPropertyValue(property))
571 569
572 570 var css = ''
573 571 for (key in property)

0 comments on commit bc7fe4c

Please sign in to comment.
Something went wrong with that request. Please try again.