Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Serializing the value of empty DOM elements using native JSON in IE8 #304

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

siyu77
Copy link

@siyu77 siyu77 commented Apr 3, 2018

How to reproduce:
OS: Windows XP
Browser: Internet Explorer 8.0.6001.18702

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>jquery-placeholder test suite</title>
		<style>
		</style>
	</head>
	<body>
		<div id="qunit"></div>
		<div id="fixtures">
			<!-- I explicitly want these to be visible in the page, for easier debugging. -->
			<form>
				<p><label><code>type=search</code> <input id="input-type-search" type="search"></label></p>
				<p><label><code>type=text</code> <input id="input-type-text" type="text"></label></p>
				<p><label><code>type=email</code> <input id="input-type-email" type="email"></label></p>
				<p><label><code>type=url</code> <input id="input-type-url" type="url"></label></p>
				<p><label><code>type=tel</code> <input id="input-type-tel" type="tel"></label></p>
				<p><label for="input-type-password"><code>type=password</code> </label><input id="input-type-password" type="password"></p>
				<p><label><code>textarea</code> <textarea id="textarea"></textarea></label></p>
				<p><input type="submit" value="type=submit"></p>
			</form>
		</div>
		<script src="../jquery.min.js"></script>
		<script src="../jquery.placeholder.js"></script>
		<script src="tests.js"></script>
	</body>
</html>
console.log(JSON.stringify($('#input-type-search').val()));
console.log(JSON.stringify($('#input-type-text').val()));
console.log(JSON.stringify($('#input-type-email').val()));
console.log(JSON.stringify($('#input-type-url').val()));
console.log(JSON.stringify($('#input-type-tel').val()));
console.log(JSON.stringify($('#input-type-password').val()));
console.log(JSON.stringify($('#input-type-textarea').val()));

Outputs:

"null"

Cause and Fix method:
See: https://blogs.msdn.microsoft.com/jscript/2009/06/22/serializing-the-value-of-empty-dom-elements-using-native-json-in-ie8/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants