tests for getEncodedText helper and issue #2547

This commit is contained in:
John Bender 2011-09-27 15:48:52 -07:00
parent ac0288a5ba
commit d816fe1ec1
4 changed files with 31 additions and 0 deletions

View file

@ -117,4 +117,9 @@
$( "#parent" ).removeWithDependents();
same($( "#parent, #dependent" ).length, 0);
});
test( "$.fn.getEncodedText should return the encoded value where $.fn.text doesn't", function() {
same( $("#encoded").text(), "foo>");
same( $("#encoded").getEncodedText(), "foo>");
});
})(jQuery);

View file

@ -31,6 +31,7 @@
<div id="qunit-fixtures">
<div id="parent"></div>
<div id="dependent"></div>
<div id="encoded">foo&gt;</div>
</div>
</body>
</html>

View file

@ -343,6 +343,10 @@
<select name="parent-themed" id="parent-themed" data-nstest-native-menu="false">
<option value="-1">default</option>
</select>
<select name="encoded-option" id="encoded-option" data-nstest-native-menu="false">
<option>&lt;script&gt;window.encodedValueIsDefined = true;&lt;/script&gt;</option>
</select>
</div>

View file

@ -6,6 +6,7 @@
var libName = "jquery.mobile.forms.select.js",
originalDefaultDialogTrans = $.mobile.defaultDialogTransition,
originalDefTransitionHandler = $.mobile.defaultTransitionHandler,
originalGetEncodedText = $.fn.getEncodedText,
resetHash, closeDialog;
resetHash = function(timeout){
@ -20,6 +21,9 @@
teardown: function(){
$.mobile.defaultDialogTransition = originalDefaultDialogTrans;
$.mobile.defaultTransitionHandler = originalDefTransitionHandler;
$.fn.getEncodedText = originalGetEncodedText;
window.encodedValueIsDefined = undefined;
}
});
@ -313,4 +317,21 @@
.siblings( "a" )
.hasClass("ui-btn-up-" + select.parents(":jqmData(role='page')").jqmData('theme')));
});
// issue #2547
test( "custom select list item links have encoded option text values", function() {
$( "#encoded-option" ).data( 'selectmenu' )._buildList();
same(window.encodedValueIsDefined, undefined);
});
// issue #2547
test( "custom select list item links have unencoded option text values when using vanilla $.fn.text", function() {
// undo our changes, undone in teardown
$.fn.getEncodedText = $.fn.text;
$( "#encoded-option" ).data( 'selectmenu' )._buildList();
same(window.encodedValueIsDefined, true);
});
})(jQuery);