Bug Tracker

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#10262 closed bug (invalid)

Empty attributes gives undefined!

Reported by: doctor Rudolf Owned by: doctor Rudolf
Priority: low Milestone: None
Component: attributes Version: 1.6.4rc1
Keywords: Cc:
Blocked by: Blocking:

Description

alert($(‘#aaa’).attr(‘myattribute’)) gives "undefined" in IE8 - before 1.6.3 gave "".

Page:

<html>
<head>
	<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js"></script>
</head>
<body>
	<form id="form1">
		<input id="aaa" myattribute=""/>
	</form>
</body>
</html>

Change History (12)

comment:1 Changed 8 years ago by timmywil

Component: unfiledattributes
Owner: set to doctor Rudolf
Priority: undecidedlow
Status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket.

Additionally, be sure to test against the jQuery Edge version to ensure the issue still exists. To get you started, use this boilerplate: http://jsfiddle.net/FrKyN/ Open the link and click to "Fork" (in the top menu) to get started.

comment:2 Changed 8 years ago by doctor Rudolf

Status: pendingnew

You CAN'T trigger it in Jsfiddle, we've tried.

It has to do with if a doctype is present or not and probably that is why it can't be triggered in Jsfiddle.

Please create the two files below and run them in IE8.

Paste this code in returnsUNDEFINED.aspx:

<html>
<head>
	<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js"></script>
</head>
<body>
	<form id="form1">
	<input id="in" emptyattr="" />
	</form>
</body>
</html>
<script>
	$(function () {
		alert($('#in').attr('emptyattr'));
	});
</script>

Paste this code in to returnsEmptyString.aspx

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js"></script>
</head>
<body>
	<form id="form1">
	<input id="in" emptyattr="" />
	</form>
</body>
</html>
<script>
	$(function () {
		alert($('#in').attr('emptyattr'));
	});
</script>

Then try changing 1.6.4 to 1.6.2 and see the difference. Surely 1.6.2 behaviour must be the correct one, don't you think?

We also recommend you to upgrade this ticket to a higher priority.

comment:3 Changed 8 years ago by timmywil

Status: newpending

There is no reason why a bug can't be reproduced on jsfiddle. This is probably an indication that the bug is no longer present. I noticed you are not testing against 1.6.4, but actually 1.6.3. Nevertheless, the most up-to-date version is the git version (also called edge) on http://jsfiddle.net. Please reproduce there for us.

comment:4 Changed 8 years ago by Doctor Rudolf

Mr Wil

Please don't give me that. I am a developer with 18 years of experience. Before I file a ticket I do my outmost not to bother guys like you with untested things. I have also gone through the this bug with collegues of mine that are gurus.

I write again: "...It has to do with if a doctype is present or not and probably that is why it can't be triggered in Jsfiddle. ...".

It might not be clear, but we've tested it in 1.6.4 - read between the lines ("...Then try changing 1.6.4...") might give you a hint. 1.6.4 was not released here in Sweden when we did the test. The day before we did tests with 1.6.4R1.

Please take some time and and do my recommended tests in IE8 - and be suprised when it don't work in plain files but in jsfiddle.

I don't write this ticket with the purpose of giving you more work - I write it solely because I believe in JQuery and the Jquery community.

Regards

comment:5 Changed 8 years ago by anonymous

Anything?

comment:6 in reply to:  3 Changed 8 years ago by Doctor Rudolf

Replying to timmywil:

Would you like me to open a new ticket or can you review my comments on the existing one?

comment:7 Changed 8 years ago by timmywil

Sorry, I didn't see your previous comments. There really isn't a reason why a bug of this nature (as in it does not rely on a certain ajax response) can't be reproduced on jsfiddle. We ask for this because in the process of creating a fiddle, users will often realize that the problem was not with jQuery, but with their own code or environment. It is not meant to insult, but is rather a tool to help us narrow down the large number of tickets we receive. We also ask for jsfiddle test cases so that the code will be hosted and easily editable by the bugs team so that we can easily investigate the problem.

We do appreciate any contributions to the project, but we also need help narrowing down issues.

comment:8 Changed 8 years ago by timmywil

Resolution: invalid
Status: pendingclosed

ajpiano has noticed that the html listed in this ticket is invalid. Nothing should be placed outside of the <html> tag, including scripts. It may be that this works anyway in most browsers, but IE8 is more strict about it, especially in quirksmode. If the script tag is placed inside of html and you have a doctype on the page and there is still an issue, we can reopen this ticket.

comment:9 Changed 8 years ago by dmethvin

I was able to reproduce this problem in IE7 and 1.6.3/1.6.4 by creating a test page, but the problem does not exist in http://code.jquery.com/jquery-git.js so it should be gone as of 1.7.

As timmywil says, we ask for complete and working test cases so we can be sure that we are seeing exactly what you are seeing. When we have to copy/paste code from place to place using snippets in the ticket, it greatly increases our debugging time and effort. We get about 10 new tickets a day, we can't afford to volunteer time debugging incomplete bug reports.

Last edited 8 years ago by dmethvin (previous) (diff)

comment:10 Changed 8 years ago by jedipunk

I just updated our Jquery to 1.6.4 and can confirm this is a problem in IE8.

I cannot get jsfiddle to work in IE8. I get a javascript error when I switch the framework to jquery; otherwise I would be happy to provide you an exmaple.

Since it is confirmed to be a bug is someone gonna fix it.

comment:11 Changed 8 years ago by Rick Waldron

create the fiddle in another browser, you will still be able to run it in IE8

comment:12 in reply to:  11 Changed 8 years ago by jedipunk

Finally got jsfiddle to work...kinda. Every time, I hit RUN it still throws a js error (Object does not support this property or method) but when I hit UPDATE it will refresh the page and run my example.

Regardless, I agree with Rudolf. The same bug does not happen in jsfiddle. Here is the example I tried: http://jsfiddle.net/xJfpX/15/

When I do the same thing in a mock page it does not return an empty string but an undefined.

Since it is confirmed to be a bug comment #9 is someone gonna change the ticket from invalid to open or is a 1.7 release right around the corner?

Note: See TracTickets for help on using tickets.