| 248 | /** |
| 249 | * Feature detecting the availability of the specified event on this document/element. |
| 250 | * @param {String} eventName |
| 251 | * @return {Boolean} true if event is supported |
| 252 | */ |
| 253 | domObjectProto.supports = (function() |
| 254 | { |
| 255 | var cache = {}; |
| 256 | function isEventSupported( eventName ) |
| 257 | { |
| 258 | var type = this.$.nodeType; |
| 259 | if ( !( type == CKEDITOR.NODE_DOCUMENT || |
| 260 | type == CKEDITOR.NODE_DOCUMENT ) ) |
| 261 | return false; |
| 262 | |
| 263 | eventName = 'on' + eventName; |
| 264 | |
| 265 | var element = this.$, |
| 266 | nodeName = element.nodeName; |
| 267 | |
| 268 | // return cached result. |
| 269 | if ( nodeName in cache ) |
| 270 | return cache[ nodeName ]; |
| 271 | |
| 272 | // When using `setAttribute`, IE skips "unload", |
| 273 | // WebKit skips "unload" and "resize", whereas `in` "catches" those |
| 274 | var isSupported = ( eventName in element ); |
| 275 | |
| 276 | if ( !isSupported ) |
| 277 | { |
| 278 | // if it has no `setAttribute` (i.e. doesn't implement Node interface), try generic element |
| 279 | if ( !element.setAttribute ) |
| 280 | element = document.createElement( 'div' ); |
| 281 | if ( element.setAttribute && element.removeAttribute ) |
| 282 | { |
| 283 | element.setAttribute( eventName, '' ); |
| 284 | isSupported = typeof element[ eventName ] == 'function'; |
| 285 | |
| 286 | // if property was created, "remove it" (by setting value to `undefined`) |
| 287 | if ( typeof element[ eventName ] != 'undefined' ) |
| 288 | element[ eventName ] = undefined; |
| 289 | element.removeAttribute( eventName ); |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | element = null; |
| 294 | return ( cache[ nodeName ] = isSupported ); |
| 295 | } |
| 296 | |
| 297 | return isEventSupported; |
| 298 | })() |
| 299 | |