These are chat archives for opal/opal

15th
Mar 2018
G. Gibson
@mistergibson
Mar 15 2018 01:38
I'm trying Browser::CSS::StyleSheet.new(document.styleSheets[0]) and getting an error: .is_a? is not a function. Am I doing this all wrong?
Mitch VanDuyn
@catmando
Mar 15 2018 04:40
@elia @/all seems a wee bug?
with_tap = false.tap {  }
puts "with the tap count = #{[with_tap].select { |x| x }.count}" # 1

without_tap = false
puts "without the tap count = #{[without_tap].select { |x| x }.count}" # 0
seems that within $send(false, $tap...) false is getting converted to new Boolean(false) which is not falsy!!!
Mitch VanDuyn
@catmando
Mar 15 2018 12:23
@/all problem seems to be in Object#send
Mitch VanDuyn
@catmando
Mar 15 2018 13:21
it would seem to be a difficult problem:
> return_self = function(x) { return this }
ƒ (x) { return this }
> return_self(12)
Window {postMessage: ƒ, blur: ƒ, focus: ƒ, close: ƒ, frames: Window, …}
> return_self.apply(false)
Boolean {false}
i.e. root problem is that apply(false) converts false to a Boolean
Elia Schito
@elia
Mar 15 2018 13:23
@catmando @sfcgeorge from what I see the problem is with Array#select not using Opal.truthy https://github.com/opal/opal/blob/elia/dollars-and-cents/opal/corelib/array.rb#L1882
Mitch VanDuyn
@catmando
Mar 15 2018 13:24
which checks for Boolean(x) as well as true and false etc?
Elia Schito
@elia
Mar 15 2018 13:25
yes, minified trythy looks like this: function (e){return e!==h&&null!=e&&(!e.$$is_boolean||1==e)} = $1
Mitch VanDuyn
@catmando
Mar 15 2018 13:25
well its four places in that file alone
Elia Schito
@elia
Mar 15 2018 13:25
  Opal.truthy = function(val) {
    return (val !== nil && val != null && (!val.$$is_boolean || val == true));
  };

  Opal.falsy = function(val) {
    return (val === nil || val == null || (val.$$is_boolean && val == false))
  };
Mitch VanDuyn
@catmando
Mar 15 2018 13:27
what a hot mess. (not opal, I mean JS)
Elia Schito
@elia
Mar 15 2018 13:38
LOL, that's why you're here I guess :smile:
Simon George
@sfcgeorge
Mar 15 2018 13:52
Hehe indeed :) I actually like writing JavaScript now (because I'm not)
Elia Schito
@elia
Mar 15 2018 14:02
@sfcgeorge that's the spirit!
Elia Schito
@elia
Mar 15 2018 15:42
:tada: just released our apps in prod with opal 0.11 and opal-rails 0.9.4
      :tot_files => 481,
      :tot_lines => 34514,
        :tot_loc => 26974,
    :tot_classes => 602,
    :tot_methods => 2264,
most fixes were relative to constant lookup
G. Gibson
@mistergibson
Mar 15 2018 18:01
@iliabylich : It appears that although opal-browser does a great job with DOM::Elements and style info - there seems no provision or support in your code for altering the CSS rules (definitions) themselves of the page globally. Am I mistaken? I can write something, but I'm hesitant to re-invent the wheel. Your thoughts?
meh.
@meh
Mar 15 2018 19:38
mistergibson, from what I recall at the time the CSSOM stuff was still buggy and awful
G. Gibson
@mistergibson
Mar 15 2018 19:48
@meh : ok, I'll go ahead and write something
thanks
meh.
@meh
Mar 15 2018 19:52
@mistergibson in general look in opal/browser/css
G. Gibson
@mistergibson
Mar 15 2018 19:52
I did
@meh : I experimented with it attempting to 'mount' the CSS defs and stuff - all to no avail
meh.
@meh
Mar 15 2018 19:53
if there's nothing there then I never got to finish it, and whatever I had done and never committed is stuck on my old laptop in another country
G. Gibson
@mistergibson
Mar 15 2018 19:53
ok
shit happens eh?
@meh : it's ok - I'm about half done with something to address it
meh.
@meh
Mar 15 2018 19:59
@mistergibson cool, if you have questions about opal-browser I can try remembering things :)
G. Gibson
@mistergibson
Mar 15 2018 20:02
@meh : thanks
Forrest Chang
@fkchang
Mar 15 2018 21:19
@meh -- long time no read - how are things? Still hacking rust?
G. Gibson
@mistergibson
Mar 15 2018 21:20
I wonder if anyone would port MRI to rust to get real concurrency - just a fantasy at this point.
meh.
@meh
Mar 15 2018 21:23
@fkchang yeah, working full time as a Rust something something, how about you?