Closed Bug 363048 Opened 18 years ago Closed 4 years ago

Warn when JavaScript accidentally creates an expando property (trying to set a "real" property with a very similar name)

Categories

(DevTools :: General, enhancement)

enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED INACTIVE

People

(Reporter: nadavvin, Unassigned)

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0

For example:

The following code wile work but if I change the title to Title it's not work

but There is no error or warning in the JavaScript console.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title></title>
<script language="javascript">
document.title="Hello World!";
</script>
</head>
<body>
</body>
</html>


Reproducible: Always

Steps to Reproduce:
1.I change One letter to capital letter
2.
3.

Actual Results:  
It's not work as it should be, but there no error report.

Expected Results:  
Error or warning

The Java script console is very important in converting male Explorer JS code to good code.

Missing errors like this only prevent many site to be Firefox friendly.
When you set document.Title (or document.FrenchFries, for that matter), you're creating an expando property.  That isn't an error.

I guess Firefox's DOM could *warn* if you create an expando property and there's another property that has the same name except for case differences.  But I don't think it should.
And what with a warning.

Maybe it is legal to use custom properties but also could be programmer mistake or it is property which work only in IE and there know way to found out which one.

I have some script like this and it will help to many other who want that their website will work correctly in other browsers
I add "document.expando = false;" and I still don't get errors.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title></title>
<script language="javascript">
document.expando = false;
document.Title="Hello World!";
</script>
</head>
<body>
</body>
</html>
"document.expando = false" is an IE-ism, I'm afraid.
Assignee: nobody → general
Component: Error Console → DOM
Product: Firefox → Core
QA Contact: javascript.console → ian
Version: unspecified → Trunk
Severity: normal → enhancement
Summary: The JavaScript console is not report errors on case sensitive javascript command. → Warn when JavaScript accidentally creates an expando property (trying to set a "real" property with a very similar name)
Setting "document.Title" doesn't have any effect for me in IE7.  Same with "document.expando", which surprises me.
You right.

It not work in IE but still need a warning.

There is warning to document.all which is not w3c recommend, so why there no same warning here?

The main reason that this warning important for me is the ability to identify IE only tags in IE only friendly scripts.

There are many website which not support and it's not simple to convert them. 
Assignee: general → nobody
QA Contact: ian → general
Component: DOM → Developer Tools
Product: Core → Firefox
Product: Firefox → DevTools
Status: UNCONFIRMED → RESOLVED
Closed: 4 years ago
Resolution: --- → INACTIVE
You need to log in before you can comment on or make changes to this bug.