Closed hsalokor closed 11 years ago
This is necessary in order to do, for example, (dommy/listen! js/window :resize #(resize! my-container))
We definitely need to listen to js/window
changes. What we need is a shim for how to make this work in PhatomJS world. Any ideas what the type is for Window or if there's a way to conditionally not eval that code?
Ah, that makes sense. Thanks :)
I'll investigate the issue further w/ phantomjs and get back to this later.
I investigated the phantomjs a bit, but I was unable to get anything sensible (like type) from the window
or Window
implementation.
As a second approach, I just updated the patch to extend the protocol PElement
conditionally, i.e. only if js/Window
exists. The (try ... (catch ...))
structure was cleanest form I could come up with. It seems to work as expected at least in my limited testing.
It also now prints message to console log if Window
is not defined, which should make debugging a bit easier.
This seems like a perfectly reasonable solution for now, thanks for the commit! We'll keep headless webkit implementations in mind, because we certainly want to be able to use stuff like phantom as a test platform.
I'm trying to use PhantomJS in order to run unit tests headlessly, and noticed following issue when upgrading to 0.1.0 from 0.0.2.
PhantomJS apparently does not have
Window
object in global Javascript scope. This seems to cause the Javascript code with(deftemplate ...)
definitions to throw following error on load:ReferenceError: Can't find variable: Window
By looking at the generated code, the culprit seems to be following lines:
I tracked it back to
PElement
definition, and those lines seem to be generated by thejs/Window
entry in the definition.Is the definition necessary? I've attached code that removes it, and at least I could not see any major issues with it. Am I missing something?