@@ -585,25 +585,25 @@ var Zepto = (function() {
585
585
prev : function ( selector ) { return $ ( this . pluck ( 'previousElementSibling' ) ) . filter ( selector || '*' ) } ,
586
586
next : function ( selector ) { return $ ( this . pluck ( 'nextElementSibling' ) ) . filter ( selector || '*' ) } ,
587
587
html : function ( html ) {
588
- return arguments . length === 0 ?
589
- ( this . length > 0 ? this [ 0 ] . innerHTML : null ) :
588
+ return 0 in arguments ?
590
589
this . each ( function ( idx ) {
591
590
var originHtml = this . innerHTML
592
591
$ ( this ) . empty ( ) . append ( funcArg ( this , html , idx , originHtml ) )
593
- } )
592
+ } ) :
593
+ ( 0 in this ? this [ 0 ] . innerHTML : null )
594
594
} ,
595
595
text : function ( text ) {
596
- return arguments . length === 0 ?
597
- ( this . length > 0 ? this [ 0 ] . textContent : null ) :
596
+ return 0 in arguments ?
598
597
this . each ( function ( idx ) {
599
598
var newText = funcArg ( this , text , idx , this . textContent )
600
599
this . textContent = newText == null ? '' : '' + newText
601
- } )
600
+ } ) :
601
+ ( 0 in this ? this [ 0 ] . textContent : null )
602
602
} ,
603
603
attr : function ( name , value ) {
604
604
var result
605
605
return ( typeof name == 'string' && value === undefined ) ?
606
- ( this . length == 0 || this [ 0 ] . nodeType !== 1 ? undefined :
606
+ ( ! this . length || this [ 0 ] . nodeType !== 1 ? undefined :
607
607
( ! ( result = this [ 0 ] . getAttribute ( name ) ) && name in this [ 0 ] ) ? this [ 0 ] [ name ] : result
608
608
) :
609
609
this . each ( function ( idx ) {
@@ -628,14 +628,14 @@ var Zepto = (function() {
628
628
return data !== null ? deserializeValue ( data ) : undefined
629
629
} ,
630
630
val : function ( value ) {
631
- return arguments . length === 0 ?
631
+ return 0 in arguments ?
632
+ this . each ( function ( idx ) {
633
+ this . value = funcArg ( this , value , idx , this . value )
634
+ } ) :
632
635
( this [ 0 ] && ( this [ 0 ] . multiple ?
633
636
$ ( this [ 0 ] ) . find ( 'option' ) . filter ( function ( ) { return this . selected } ) . pluck ( 'value' ) :
634
637
this [ 0 ] . value )
635
- ) :
636
- this . each ( function ( idx ) {
637
- this . value = funcArg ( this , value , idx , this . value )
638
- } )
638
+ )
639
639
} ,
640
640
offset : function ( coordinates ) {
641
641
if ( coordinates ) return this . each ( function ( index ) {
@@ -650,7 +650,7 @@ var Zepto = (function() {
650
650
if ( $this . css ( 'position' ) == 'static' ) props [ 'position' ] = 'relative'
651
651
$this . css ( props )
652
652
} )
653
- if ( this . length == 0 ) return null
653
+ if ( ! this . length ) return null
654
654
var obj = this [ 0 ] . getBoundingClientRect ( )
655
655
return {
656
656
left : obj . left + window . pageXOffset ,
0 commit comments