Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Move RenderContext's windowWrapper to one singleton object on the pro…

…totype.
  • Loading branch information...
commit 42ca26cd082a4b6d6ce6840943dfeddbc966928d 1 parent 77a0c97
Harry Brundage airhorns authored
Showing with 6 additions and 4 deletions.
  1. +4 −3 lib/batman.js
  2. +2 −1  src/batman.coffee
7 lib/batman.js
View
@@ -6919,6 +6919,10 @@
}
};
+ RenderContext.prototype.windowWrapper = {
+ window: window
+ };
+
function RenderContext(object, parent) {
this.object = object;
this.parent = parent;
@@ -6936,9 +6940,6 @@
}
currentNode = currentNode.parent;
}
- this.windowWrapper || (this.windowWrapper = {
- window: Batman.container
- });
return [$get(this.windowWrapper, key), this.windowWrapper];
};
3  src/batman.coffee
View
@@ -4149,6 +4149,8 @@ class Batman.RenderContext
Batman.currentApp.get('_renderContext')
else
@base
+
+ windowWrapper: {window}

shouldn't this be windowWrapper: Batman.container

Harry Brundage Collaborator

When in the browser window is the value of Batman.container but in node Batman.container is node's global object. If you are in node and using something like jsdom you might have a window variable so I figured that it would be better to explicitly reference the window so the view renders in the context you expect. This assumes however the window var is available globally so Batman can even reference so it's a bit of a longshot.

Has this broken something for you? I suppose someone could actually want to wrap node's global object if they are doing rendering in node...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
constructor: (@object, @parent) ->
findKey: (key) ->
@@ -4163,7 +4165,6 @@ class Batman.RenderContext
return [val, currentNode.object].map(@constructor.deProxy)
currentNode = currentNode.parent
- @windowWrapper ||= window: Batman.container
[$get(@windowWrapper, key), @windowWrapper]
get: (key) -> @findKey(key)[0]

2 comments on commit 42ca26c

Christian Ehrhardt

shouldn't this be windowWrapper: Batman.container

Harry Brundage
Collaborator

When in the browser window is the value of Batman.container but in node Batman.container is node's global object. If you are in node and using something like jsdom you might have a window variable so I figured that it would be better to explicitly reference the window so the view renders in the context you expect. This assumes however the window var is available globally so Batman can even reference so it's a bit of a longshot.

Has this broken something for you? I suppose someone could actually want to wrap node's global object if they are doing rendering in node...

Christian Ehrhardt

ya the batman cli tool stopped working for me, complaining window didn't exist

Christian Ehrhardt

perhaps change it to windowWrapper: window?

Please sign in to comment.
Something went wrong with that request. Please try again.