@@ -54,6 +54,15 @@ export const isBrowser: boolean =
5454export function patchProperty ( obj , prop ) {
5555 const desc = Object . getOwnPropertyDescriptor ( obj , prop ) || { enumerable : true , configurable : true } ;
5656
57+ const originalDesc = Object . getOwnPropertyDescriptor ( obj , 'original' + prop ) ;
58+ if ( ! originalDesc && desc . get ) {
59+ Object . defineProperty ( obj , 'original' + prop , {
60+ enumerable : false ,
61+ configurable : true ,
62+ get : desc . get
63+ } ) ;
64+ }
65+
5766 // A property descriptor cannot have getter/setter and be writable
5867 // deleting the writable and value properties avoids this error:
5968 //
@@ -89,6 +98,23 @@ export function patchProperty(obj, prop) {
8998 // The getter would return undefined for unassigned properties but the default value of an
9099 // unassigned property is null
91100 desc . get = function ( ) {
101+ let r = this [ _prop ] || null ;
102+ // result will be null when use inline event attribute,
103+ // such as <button onclick="func();">OK</button>
104+ // because the onclick function is internal raw uncompiled handler
105+ // the onclick will be evaluated when first time event was triggered or
106+ // the property is accessed, https://github.com/angular/zone.js/issues/525
107+ // so we should use original native get to retrive the handler
108+ if ( r === null ) {
109+ let oriDesc = Object . getOwnPropertyDescriptor ( obj , 'original' + prop ) ;
110+ if ( oriDesc && oriDesc . get ) {
111+ r = oriDesc . get . apply ( this , arguments ) ;
112+ if ( r ) {
113+ desc . set . apply ( this , [ r ] ) ;
114+ this . removeAttribute ( prop ) ;
115+ }
116+ }
117+ }
92118 return this [ _prop ] || null ;
93119 } ;
94120
0 commit comments