Closed Bug 265042 Opened 20 years ago Closed 20 years ago

Javascript strict warnings : function _ does not always return a value

Categories

(Core :: JavaScript Engine, defect, P4)

defect

Tracking

()

RESOLVED FIXED
mozilla1.8alpha5

People

(Reporter: math.parent, Assigned: brendan)

Details

(Keywords: fixed-aviary1.0, fixed1.7.5, js1.5)

Attachments

(2 files)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8a5) Gecko/20041018
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8a5) Gecko/20041018

This is a "strict" error incoming only if "javascript.options.strict=true"
(about:config)

If an html element has an event attribute like 
onclick="javascript:return(returnValue('yes'));", then the javascript console
shows a strict warning :

Warning:function onclick does not always return a value

whereas the function returnValue always returns a value.

Reproducible: Always
Steps to Reproduce:
1. Set javascript.options.strict=true in about:config
2. Go to the test case
3. Open the javascript console
4. Clear the javascript console
3. Click on a radio button

Actual Results:  
Javascript console:
Warning:function onclick does not always return a value

Expected Results:  
Javascript console:
[nothing]

This bug is also on FireFox
Attached file Test case
test it
The warning is not displayed if "javascript:" is removed from the attribute value. 
in the w3c recommendation, you have to put:

  <meta http-equiv="Content-Script-Type" content="text/javascript">

in the <head>

then "javascript:" is not needed.

I hope this works with old browsers, then we can close this small bug
javascript: is *never* necessary as a URL scheme, at the front of an onclick
attribute value.  Such a value is a JS program, so javascript:, or L: or foo:,
is a *label*.  It's a useless label, which confuses the JS engine's diagnostic
into misreporting the problem.  I'll fix that now.

/be
Assignee: general → brendan
Status: UNCONFIRMED → NEW
Ever confirmed: true
Status: NEW → ASSIGNED
Keywords: js1.5
Priority: -- → P4
Target Milestone: --- → mozilla1.8alpha5
Attached patch fixSplinter Review
Probably I'll check this in r=self, trunk and branches.

/be
Mathieu, in case comment 4 was unclear: you can't cause an onclick handler to be
interpreted using a particular script engine by putting javascript: or vbscript:
or whatever at the front of the onclick attribute's value string.

If you know of a browser that respects that, let me know.  You cited the w3c
HTML 4 approved away of setting the "default script language", using a header or
a META tag -- does that work in Gecko?  It should, but I thought I would ask!

/be
Fixed everywhere.

/be
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Flags: blocking1.7.x+
Flags: blocking-aviary1.0+
Resolution: --- → FIXED
Comment on attachment 162641 [details] [diff] [review]
fix

post-facto review is better than no-facto review, I always say.
Attachment #162641 - Flags: review+
Flags: testcase?
Flags: in-testsuite? → in-testsuite-
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: