What steps will reproduce the problem?
1. prepare a form:
<form id="myform">
<input name="pw">
</form>
2. listen some event use the closure-lib api:
goog.events.listen(form, 'submit', fn)
3. compile in advance mode
What is the expected output? What do you see instead?
failed to listen submit event.
What version of the product are you using? On what operating system?
- some particular version
- "5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.19 (KHTML, like
Gecko) Chrome/18.0.1025.165 Safari/535.19"
Please provide any additional information below.
## Cause
http://code.google.com/p/closure-library/source/browse/trunk/closure/goog/events
/events.js#215
if (src.addEventListener) {
if (src == goog.global || !src.customEvent_) {
src.addEventListener(type, proxy, capture);
}
}
It failed because the `customEvent_` prop compiled to `pw', and `myform.pw` is
and input element.
I viewed the compiled results in three environments, the `customEvent_` prop
compiled to shorter names such as pw, tx, and Lx:
env 1:
if (a.addEventListener) {
if (a == q || !a.pw)
a.addEventListener(b, j, d)
}
env 2:
if (a.addEventListener) {
if (a == q || !a.tw)
a.addEventListener(b, j, d)
}
env 3:
if (a.addEventListener) {
if (a == q || !a.Lx)
a.addEventListener(b, j, d)
}
## Solve
In my opinion, I thinked about three ways to solve the problem:
- the safer one, do not detect expando, hide it
internelcache = {}
var isCustomEvents = internel_cache[ element[goog.UIDPROPERTY]
][customEvents]
if (isCustomEvents_) then ...
- ignore the naming and third-party libs
// strict type compare
if ( element.cutomEvent === true) then …
// or, disable compile it
if ( element['customEvent] ) then...
Original issue reported on code.google.com by ambar....@gmail.com on 28 Apr 2012 at 11:13
if (src.addEventListener) { if (src == goog.global || !src.customEvent_) { src.addEventListener(type, proxy, capture); } }
internelcache = {} var isCustomEvents = internel_cache[ element[goog.UIDPROPERTY] ][
customEvents
] if (isCustomEvents_) then ...// strict type compare if ( element.cutomEvent === true) then … // or, disable compile it if ( element['customEvent] ) then...
Original issue reported on code.google.com by
ambar....@gmail.com
on 28 Apr 2012 at 11:13