4 ms·
I get a reference error when I try this (chrome stable on linux)
by r14n 2y ago
I get a reference error when I try this (chrome stable on linux)
- myfonj 2y agoAh, thanks for the heads-up, apparently there is something borked in Chromium wrt $ / $$ encapsulation, as it seems they are nor reachable from the (global) context setInterval so doing `window.$ = $; window.$$ = $$;` fixes that in Chrome. Not sure why. (Yet again embarrassed myself by trying a snippet that "simply must work ® according all documentations ™" in single a browser only before posting. Sigh.)
- myfonj 2y agoFiled as https://issues.chromium.org/issues/388437264 https://issues.chromium.org/issues/388437264
- throwaway127482 2y agoI bet it's working as intended. The $ symbol is probably a special feature of the console and is not intended to be a property of window. Inside setInterval, the function is no longer being executed in the special console environment, which has access to that symbol.
- myfonj 2y agoYes, I guess there could be some intention behind that, presumably some security precautions, but still: the fact that you can see $ in the globalThis (as a non-enumerable prop), and that globalThis you see from inside the timeout-ed function is strictly equal to globalThis seen directly from the console, that makes it somewhat spooky. console.log(Object.getOwnPropertyDescriptor(globalThis, '$')) // {writable: true, enumerable: true, configurable: true, value: f} globalThis.globalThat = globalThis globalThat.$ === globalThis.$ // true setTimeout(()=>console.log(globalThis.globalThat === globalThis)) // true setTimeout(()=>console.log(Object.getOwnPropertyDescriptor(globalThis, '$'))) // undefined (!) $ = $ setTimeout(()=>console.log(Object.getOwnPropertyDescriptor(globalThis, '$'))) // { writable: true, enumerable: true, configurable: true, value: f} And it (`setTimeout(()=>{console.log(typeof $==="function")},0)`) works in Firefox. (Interestingly, you cannot get $'s descriptor in there, but you have it always available in timeout.)
- myfonj 2y agoWas closed as "Infeasible", i.e. wontfix.