고급 컴파일 모드에서 오류가 발생합니다. Google 폐쇄 이벤트 타겟은 어떻게 작동합니까?
Uncaught TypeError: Object #<d> has no method 'attachEvent'
는 일부 소스지도 마법 후 나는이 첫 번째 인수
goog.events.EventTarget
상속, 내 사용자 정의 개체입니다
goog.events.listen
전화에서 발생되는 생각.
이 클로저의 소스
goog.events.EventTarget.prototype.addEventListener = function(
type, handler, opt_capture, opt_handlerScope) {
goog.events.listen(this, type, handler, opt_capture, opt_handlerScope);
};
에 그래서이 기능이
// Attach the proxy through the browser's API
if (src.addEventListener) {
if (src == goog.global || !src.customEvent_) {
src.addEventListener(type, proxy, capture);
}
} else {
// The else above used to be else if (src.attachEvent) and then there was
// another else statement that threw an exception warning the developer
// they made a mistake. This resulted in an extra object allocation in IE6
// due to a wrapper object that had to be implemented around the element
// and so was removed.
src.attachEvent(goog.events.getOnString_(type), proxy);
}
goog.events.listen
에 다음 customEvent_ = true
와 함께, 내 객체의 프로토 타입에 끝 (마지막 줄은 발생 하나입니다)
스택 오버플로가 발생하지 않아야합니까? 내 개체가 addEventListener
에서 상속 받으면 else
분기로 들어가는 이유는 EventTarget
입니까? 간단한 컴파일 모드에서는 모든 것이 잘 동작합니다. 이 방법은 어떻게 작동하며 고급 컴파일 모드에서만 오류가 발생합니까?
개체의 실제 구현을 공유해주십시오. – zakelfassi