Skip to content

Instantly share code, notes, and snippets.

@dexteryy
Last active December 22, 2015 17:08
Show Gist options
  • Save dexteryy/6503598 to your computer and use it in GitHub Desktop.
Save dexteryy/6503598 to your computer and use it in GitHub Desktop.
对比 accessor API
// jQuery 1.4.4
$('<button></button>').val() // ""
$('<button></button>').val(undefined) // [<button value></button>]
$('<button></button>').val(null) // [<button value></button>]
$('<button></button>').html() // ""
$('<button></button>').html(undefined) // ""
$('<button></button>').html(null) // [<button></button>]
$('<button></button>').text() // ""
$('<button></button>').text(undefined) // ""
$('<button></button>').text(null) // ""
$('<button></button>').css('display') // ""
$('<button></button>').css('display', undefined) // [<button></button>]
$('<button></button>').css('display', null) // [<button></button>]
$('<button></button>').data('yy') // undefined
$('<button></button>').data('yy', undefined) // undefined
$('<button></button>').data('yy', null) // [<button></button>]
$('<button></button>').attr('yy') // undefined
$('<button></button>').attr('yy', undefined) // undefined
$('<button></button>').attr('yy', null) // [<button yy="null"></button>]
// jQuery 1.8.3
$('<button></button>').val() // ""
$('<button></button>').val(undefined) // [<button value></button>]
$('<button></button>').val(null) // [<button value></button>]
$('<button></button>').html() // ""
$('<button></button>').html(undefined) // [<button></button>]
$('<button></button>').html(null) // [<button></button>]
$('<button></button>').text() // ""
$('<button></button>').text(undefined) // [<button></button>]
$('<button></button>').text(null) // [<button>null</button>]
$('<button></button>').css('display') // ""
$('<button></button>').css('display', undefined) // [<button></button>]
$('<button></button>').css('display', null) // [<button></button>]
$('<button></button>').data('yy') // undefined
$('<button></button>').data('yy', undefined) // [<button></button>]
$('<button></button>').data('yy', null) // [<button></button>]
$('<button></button>').attr('yy') // undefined
$('<button></button>').attr('yy', undefined) // [<button></button>]
$('<button></button>').attr('yy', null) // [<button></button>]
// Zepto 1.0-1
$('<button></button>').val() // ""
$('<button></button>').val(undefined) // ""
$('<button></button>').val(null) // [<button value></button>]
$('<button></button>').html() // ""
$('<button></button>').html(undefined) // ""
$('<button></button>').html(null) // [<button></button>]
$('<button></button>').text() // ""
$('<button></button>').text(undefined) // ""
$('<button></button>').text(null) // [<button>null</button>]
$('<button></button>').css('display') // ""
$('<button></button>').css('display', undefined) // [<button></button>]
$('<button></button>').css('display', null) // [<button></button>]
$('<button></button>').data('yy') // undefined
$('<button></button>').data('yy', undefined) // undefined
$('<button></button>').data('yy', null) // [<button></button>]
$('<button></button>').attr('yy') // null
$('<button></button>').attr('yy', undefined) // null
$('<button></button>').attr('yy', null) // [<button></button>]
// DollarJS
$('<button></button>').val() // ""
$('<button></button>').val(undefined) // ""
$('<button></button>').val(null) // [<button value></button>]
$('<button></button>').html() // ""
$('<button></button>').html(undefined) // ""
$('<button></button>').html(null) // [<button></button>]
$('<button></button>').text() // ""
$('<button></button>').text(undefined) // ""
$('<button></button>').text(null) // [<button>null</button>]
$('<button></button>').css('display') // ""
$('<button></button>').css('display', undefined) // ""
$('<button></button>').css('display', null) // [<button></button>]
$('<button></button>').data('yy') // undefined
$('<button></button>').data('yy', undefined) // undefined
$('<button></button>').data('yy', null) // [<button></button>]
$('<button></button>').attr('yy') // null
$('<button></button>').attr('yy', undefined) // null
$('<button></button>').attr('yy', null) // [<button></button>]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment