You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the constructor, the driver creates a function that maps to bracket, switches its internal prototype (__proto__) to Termbase. This is what let you do things like
r.expr({foo: "bar"})("foo")
// instead of
r.expr({foo: "bar"}).bracket("foo")
You could have TermBase be an empty constructor and everything will work fine. You'll have to use .bracket(...) instead of (...) though.
If you really want to remove __proto__ without changing the same behavior, you can use ES6 proxy, but I think it's supported on Chrome and Firefox only :) It's also heavy-ish to do as you have to define the getter for all methods every time
@danielmewes Yes, it's important for my use case with rethinkdb-websocket-client, which wraps the official driver for use in the browser. But it sounds like the javascript API would have to change in order to support that, which is pretty unfortunate.
Unless there's another way to allow function calls on objects with prototypes, it's probably best not to change it. Ideally it would check if __proto__ is supported in the current environment, and if not, fail gracefully in a way that only disables the bracket shorthand.
@neumino I've tried changing TermBase to have an empty constructor (and a variety of other implementations) and I still get errors, e.g. orderBy is not a function. I don't have any bracket operations in my query. So I think there is more to do in order to get everything else working without __proto__.
This should be possible, but may require significant refactoring. jQuery, for example, implements this same sort of API and they do so without modifying __proto__. Take a look at the code here.
Their implementation is arguably cleaner than how things are currently being done in ast.coffee, but like I said this would require a decent amount of work not a quick-fix.
The other IE10 issues were my own unrelated issues.
After taking @neumino's suggestion to replace the TermBase constructor, and adding explicit .bracket(...) calls to my queries, the driver works in IE10.
Would it be acceptable to modify the TermBase constructor, to something like this (sorry, not familiar with coffeescript so hopefully my syntax is right)?
constructor:->if ({})['__proto__']
self= (ar (field) ->self.bracket(field))
self.__proto__=@.__proto__return self
elsereturnthis
Activity
danielmewes commentedon Jan 17, 2014
Wonder if it works with IE 11. Will try that out some time.
mikemintz commentedon Jul 8, 2015
I'm pretty sure it doesn't work with IE10 because IE10 doesn't support
__proto__, which is used in TermBase's constructor.rethinkdb/drivers/javascript/ast.coffee
Line 56 in 89144e1
Removing that line gives me the same error in chrome that I get in IE10, so I'm fairly sure it's a culprit.
I'm trying to work out how to get the same behavior without
__proto__, but I'm not sure what that constructor is doing exactly.neumino commentedon Jul 9, 2015
In the constructor, the driver creates a function that maps to
bracket, switches its internal prototype (__proto__) to Termbase. This is what let you do things likeYou could have TermBase be an empty constructor and everything will work fine. You'll have to use
.bracket(...)instead of(...)though.If you really want to remove
__proto__without changing the same behavior, you can use ES6 proxy, but I think it's supported on Chrome and Firefox only :) It's also heavy-ish to do as you have to define the getter for all methods every timedanielmewes commentedon Jul 9, 2015
@mikemintz Is IE 10 support important for you?
mikemintz commentedon Jul 9, 2015
@danielmewes Yes, it's important for my use case with rethinkdb-websocket-client, which wraps the official driver for use in the browser. But it sounds like the javascript API would have to change in order to support that, which is pretty unfortunate.
Unless there's another way to allow function calls on objects with prototypes, it's probably best not to change it. Ideally it would check if
__proto__is supported in the current environment, and if not, fail gracefully in a way that only disables thebracketshorthand.@neumino I've tried changing TermBase to have an empty constructor (and a variety of other implementations) and I still get errors, e.g.
orderByis not a function. I don't have any bracket operations in my query. So I think there is more to do in order to get everything else working without__proto__.marshall007 commentedon Jul 9, 2015
This should be possible, but may require significant refactoring.
jQuery, for example, implements this same sort of API and they do so without modifying__proto__. Take a look at the code here.Their implementation is arguably cleaner than how things are currently being done in
ast.coffee, but like I said this would require a decent amount of work not a quick-fix.neumino commentedon Jul 10, 2015
@mikemintz -- Did you replace the TermBase constructor with
function() { return this }?It works fine for me.
@marshall007 -- jQuery API is a less fexible.
$is a function but not what it returnsmikemintz commentedon Jul 10, 2015
@neumino My bad, that actually does work for me. Turns out there I was doing
r.row('createdAt')which was using the bracket shorthand.I still have other issues with IE10, but let me spend some time getting to the root cause of them.
mikemintz commentedon Jul 10, 2015
The other IE10 issues were my own unrelated issues.
After taking @neumino's suggestion to replace the TermBase constructor, and adding explicit
.bracket(...)calls to my queries, the driver works in IE10.Would it be acceptable to modify the TermBase constructor, to something like this (sorry, not familiar with coffeescript so hopefully my syntax is right)?
danielmewes commentedon Jul 14, 2015
@deontologician How does that change to
TermBaselook to you?deontologician commentedon Jul 14, 2015
That seems reasonable
20 remaining items
mikemintz commentedon Mar 30, 2016
Now that this is merged and 2.2.6 is released, could you publish a new RethinkDB JavaScript driver release on npm?
danielmewes commentedon Mar 30, 2016
@mikemintz The latest JavaScript driver 2.2.3 includes the change. Have you tried it?
mikemintz commentedon Mar 31, 2016
@danielmewes you're right, I am able to get it to work with 2.2.3 in IE10. Thanks!
Require rethinkdb javascript driver 2.2.3
Require rethinkdb-websocket-client 0.4.7
Require rethinkdb-websocket-client 0.4.7
Require rethinkdb-websocket-client 0.4.7
Require rethinkdb javascript driver 2.2.3
Require rethinkdb javascript driver 2.2.3
Only set __proto__ in TermBase if it exists
board: tick rethinkdb#162 — WORK tick closed RT-GAP-022/023/024 (modu…