These are chat archives for opal/opal

18th
May 2015
Jeremy Evans
@jeremyevans
May 18 2015 00:02
@elia A couple other questions. 1) How would you feel about moving sprockets from a runtime dependency to a development dependency, and having the tilt runtime dependency support >=1.4? 2) Would you consider supporting syntax allowing you to call javascript methods (e.g. obj.$method() in ruby calls obj.method() in javascript)?
Adam Beynon
@adambeynon
May 18 2015 09:03
@jeremyevans I have looked at a syntax based way to call into javascript land, and in honesty it is something I would love to add. It’s just a matter of deciding on something that won’t break anything on the ruby side
Originally Opal did use obj::foo() style calls to compile down into regular javascript calls, but as we started using ruby libraries, such as rspec, mspec etc it was no longer viable
I also wondered about something like a compiler trigger
object.js.foo() would compile to object.foo(), or someything like that (and perhaps something better than .js)
but, any suggestions would be great :+1:
@fkchang autocomplete stuff is looking great! :smile:
Elia Schito
@elia
May 18 2015 11:52
@adambeynon ping, you have a minute?
  def has_attribute?(name)
    `!!self.attr(name)`
  end
I think should be:
  def has_attribute?(name)
    `self.attr(name) !== undefined`
  end
but it can potentially break apps
(backstory is that jquery returns an empty string if the attribute is there but has no value set)
Adam Beynon
@adambeynon
May 18 2015 11:56
@elia yes, agree with that. Better fit for behaviour. (not sure if undefined vs. null makes any difference)
Elia Schito
@elia
May 18 2015 11:56
@adambeynon good, will check again docs and push the change
As of jQuery 1.6, the .attr() method returns undefined for attributes that have not been set.
@adambeynon also updating Element#[]
  def [](name)
    %x{
      var value = self.attr(name);
      if(value === undefined) return nil;
      return value;
    }
  end
Elia Schito
@elia
May 18 2015 12:04
uh, this is funny:
  • Element#[] and Element#attr now return nil for empty attributes,
    instead of returning an empty string.
from the changelog
Adam Beynon
@adambeynon
May 18 2015 12:25
hmmm. I do remember changing that. maybe we were returning the same result for empty strings AND missing attributes
your proposed behaviour is the one we should be using
Elia Schito
@elia
May 18 2015 12:26
@adambeynon yes, I checked, what about making Element#[]= remove attribute when assigned nil?
Adam Beynon
@adambeynon
May 18 2015 12:28
@elia yeap, sounds good.
I will look at anything I have fixed in apps for opal-jquery
might as well do a big release for 0.8.0
Im sure I have a few monkey patches somewhere
Elia Schito
@elia
May 18 2015 12:29
eheh, that's what I'm doing too
Adam Beynon
@adambeynon
May 18 2015 12:30
@elia I really need to blog about some of my app stuff. I now have model validations and processors that run on rails, opal (webapp) AND rubymotion. The only difference is the view layer for each
its beautiful.
Elia Schito
@elia
May 18 2015 12:31
Can't wait for it, please do :clap:
@adambeynon have started any draft for the post?
Elia Schito
@elia
May 18 2015 16:11
@adambeynon this is for you :wink2: https://twitter.com/rubymotion/status/600332643620790273
Adam Beynon
@adambeynon
May 18 2015 16:49
eeek, will do! It should also cover my transition from Cordova/PhoneGap => WKWebView
much more pleasant experience
(and metal speedzzz)
Forrest Chang
@fkchang
May 18 2015 17:23
@elia is crowd sourcing peer pressure for @adambeynon to blog, that's what the internet is for
AstonJ
@AstonJ
May 18 2015 17:23
Haha nice one @elia - I shall look forward to the post @adambeynon :)
Forrest Chang
@fkchang
May 18 2015 17:32
@adambeynon what can we do to improve handling compile errors in opal-rspec? I have 2 examples of things that can really throw you off
  • if a spec file doesn't compile, the spec runner just ignores it, so you can get green, so if u don't pay attention to the spec count, you think the build is passing.
  • no stack trace when there is an error. I'm having this issue right now where specs that should pass cause a bunch of stuff totally unrelated to break, comment them out, and everything is normal. The only info is this
      TypeError:
         wrong argument type Method (expected Proc/Method)
Mitch VanDuyn
@catmando
May 18 2015 17:46
Is there any hacky way to get the callers binding
In opal?
In other words how to implement binding soft caller gem in opal. Just a hint is all I need
meh.
@meh
May 18 2015 17:56
catmando, I don't think that's possible
Forrest Chang
@fkchang
May 18 2015 17:57
@meh ur opinions would be appreciated on https://gist.github.com/jgaskins/9de193f4babcb56da4ee
meh.
@meh
May 18 2015 17:59
fkchang, paggio is technically already a virtual dom, as in it uses an internal DOM representation
that's where the virtual DOM of paggio gets converted to the actual DOM
so it shouldn't be too hard to make it rerender only when required
Forrest Chang
@fkchang
May 18 2015 18:14
@meh would it be easy to do DOM diffs? I think @jgaskins and everyone else who seems to be basically reimplementing paggio should try to standardize, unless there's some tech reason not to
meh.
@meh
May 18 2015 18:14
fkchang, I think so, everything is already stored in the object
it should just be a simple recursive function
Forrest Chang
@fkchang
May 18 2015 18:25
@meh then w/virtual dom diffs and server side rendering of components, lissio could be invinceable
Jamie Gaskins
@jgaskins
May 18 2015 18:35
@fkchang @meh Interesting, I figured it was just doing string concatenation. :+1:
@fkchang I was actually in the middle of writing up a GH issue for Clearwater based on our discussion on the gist when you tweeted at me to get in here. :-)
Forrest Chang
@fkchang
May 18 2015 18:39
@jgaskins I figured that while @meh was actually online, I'd hit him up
Jamie Gaskins
@jgaskins
May 18 2015 18:40
The virtual DOM library Clearwater's using is pretty impressive. I didn't write it, but I kinda like it. I need to clean up its Opal bindings, though.
@fkchang I'm not actually reimplementing Paggio, though. Just added some convenience methods to a mixin to sanitize and generate nodes for that virtual DOM implementation.
The idea is that, as long as an object's render method returns a scalar, a virtual DOM node, or an array of any combination of those, that's all that's needed.
Forrest Chang
@fkchang
May 18 2015 18:56
@jgaskins yours doesn't look as close to paggio as some others I've seen
Elia Schito
@elia
May 18 2015 20:27
@fkchang dang it! you exposed my little scheme!
Forrest Chang
@fkchang
May 18 2015 21:02
@elia if it makes @adambeynon blog, it'll be worth it
BTW, I added the global and class dot completion to opal-irb
Elia Schito
@elia
May 18 2015 21:19
@fkchang great stuff! can't wait to try it
Forrest Chang
@fkchang
May 18 2015 21:24
@adambeynon I'm using regexps for the tab completion, I suppose I should probably use some kind of AST assist instead, as I want to support fully qualified classnames which means changing the regexps