Fix unsafeWindow for the newer versions of Chrome. #968

This commit is contained in:
Nicolas Stepien 2013-03-26 02:58:53 +01:00
parent 7cfd5e9d5d
commit ffea1676fd

View File

@ -193,9 +193,15 @@ $.extend $,
unsafeWindow unsafeWindow
else # Chrome else # Chrome
do -> do ->
p = d.createElement 'p' uw = null
p.setAttribute 'onclick', 'return window' captureUW = (e) -> uw = e.detail
p.onclick() window.addEventListener 'unsafe', captureUW, false
s = d.createElement 'script'
s.textContent = 'window.dispatchEvent(new CustomEvent("unsafe", {detail: window}))'
(d.head or doc).appendChild s
s.parentNode.removeChild s
window.removeEventListener 'unsafe', captureUW, false
uw
bytesToString: (size) -> bytesToString: (size) ->
unit = 0 # Bytes unit = 0 # Bytes
while size >= 1024 while size >= 1024