Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 481245

Summary: [HTML] onClick and on* event attributes are not added to CU based on case
Product: [ECD] Orion Reporter: Steve Northover <steve_northover>
Component: JS ToolsAssignee: Curtis Windatt <curtis.windatt.public>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: curtis.windatt.public, Michael_Rennie
Version: 10.0   
Target Milestone: 11.0   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Bug Depends on: 481137    
Bug Blocks:    

Description Steve Northover CLA 2015-11-02 10:55:36 EST
1) get minesweeper-object
2) open button.html
3) hover over quick fix for line 12 (ie. "function onClick(ev) { ...")
3) BUG: 'Function onClick is not used'

The onClick() function is referenced later in the HTML file:

<body>
	<button onClick="onClick()"><img src="images/happy.gif"></button>
	<!-- <button onClick="click()"><img src="images/sad.gif"></button> -->
</body>
Comment 1 Curtis Windatt CLA 2015-11-02 16:17:51 EST
There is some weirdness here due to Bug 481137 with the prefix being added and I  will add comments to that bug.  But there is another significant problem specific to this case: It appears we are using a case sensitive check for on* attributes (onClick is ignored).
Comment 2 Curtis Windatt CLA 2015-11-02 16:20:50 EST
To be specific, the regex is run case insensitive but our list of known attributes is using object keys.
Comment 3 Curtis Windatt CLA 2015-11-02 17:31:57 EST
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=cfc00781284d35207ae3629e75b97ab67f7916a5
Fixed the case issue as well as an offset issue in findScriptBlocks

http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=6095b10761a31439d065dcff1cbe3d4e7607e96d
Add tests for case sensitivity,  fix tests for offset issue.
Comment 4 Steve Northover CLA 2015-11-03 13:46:55 EST
The exact test case in this example does not work.  I tried changing the bogus case from onClick to onclick and it made no difference.
Comment 5 Curtis Windatt CLA 2015-11-03 13:52:14 EST
(In reply to Steve Northover from comment #4)
> The exact test case in this example does not work.  I tried changing the
> bogus case from onClick to onclick and it made no difference.

That initial case is actually a dupe of 481137.  Fixing the case issue means it is treated as a snippet, but we are still prepending is with 'this.' resulting in eslint thinking the function is unused.

I have code in my workspace which will be committed under 481137 that removes the prefixing and fixes this case.  I did however leave a question on that bug about whether we ever want to see 'unused function' warnings in HTML files.
Comment 6 Steve Northover CLA 2015-11-03 13:57:33 EST
Ummm ... you can't close a bug as FIXED when it has a set of steps that still show the problem.  You can close it as a DUP or say it depends on another bug or that the steps are invalid or ...
Comment 7 Steve Northover CLA 2015-11-03 14:13:39 EST
Spoke to Curtis and we agree to reopen the bug and close it when the dependent bug is fixed.
Comment 8 Steve Northover CLA 2015-11-04 11:58:58 EST
I have verified that the steps in this bug report no longer show a problem.  Normally I would just close the bug.  Is there any reason you want this bug to remain open?  If not, just close as FIXED.
Comment 9 Curtis Windatt CLA 2015-11-04 15:12:34 EST
Now that Bug 481137 is closed this should be closed too.