]> source.dussan.org Git - jquery.git/commitdiff
Attrs: Fix valHook for option element 1486/head
authorOleg <markelog@gmail.com>
Wed, 15 Jan 2014 22:05:57 +0000 (02:05 +0400)
committerOleg <markelog@gmail.com>
Wed, 15 Jan 2014 23:21:25 +0000 (03:21 +0400)
Fixes #14686

src/attributes/val.js
test/unit/attributes.js

index 8454e80d038d1a4c2eb00076f87a046758859153..16296a6316ccd9cbf8203a4e7a51da937e7cfc9a 100644 (file)
@@ -71,11 +71,10 @@ jQuery.extend({
        valHooks: {
                option: {
                        get: function( elem ) {
-                               // Use proper attribute retrieval(#6932, #12072)
                                var val = jQuery.find.attr( elem, "value" );
                                return val != null ?
                                        val :
-                                       elem.text;
+                                       jQuery.text( elem );
                        }
                },
                select: {
index 8ba2b44596e820947b08b945b98b040d42b023da..2b2eee4259d07605c364c81c074fd86203b3b09d 100644 (file)
@@ -1448,3 +1448,12 @@ test( "coords returns correct values in IE6/IE7, see #10828", function() {
        area = map.html("<area shape='rect' coords='0,0,0,0' href='#' alt='a' />").find("area");
        equal( area.attr("coords"), "0,0,0,0", "did not retrieve coords correctly" );
 });
+
+test( "should not throw at $(option).val() (#14686)", 1, function() {
+       try {
+               jQuery( "<option/>" ).val();
+               ok( true );
+       } catch ( _ ) {
+               ok( false );
+       }
+});