Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Aug 23 2021 09:24
    @sjrd banned @yensaoxuan_twitter
  • Apr 18 2021 19:06
    @sjrd banned @Amitgup48798297_twitter
  • Mar 29 2021 07:47
    @sjrd banned @quangs
  • Jan 23 2021 06:34
    @sjrd banned @Rebeka58_gitlab
  • Jun 08 2020 20:43
    @sjrd banned @sw7240614
  • Sep 29 2019 08:35
    @sjrd banned @8bitpitRBX_twitter
  • May 23 2019 13:44
    @sjrd banned @BIGCRYPTO001_gitlab
  • May 01 2019 14:31
    @sjrd banned @Certificates1_gitlab
  • Apr 22 2019 15:31
    @sjrd banned @lerbatax
  • Jan 31 2019 23:04
    sjrd commented #3555
  • Jan 31 2019 22:56
    sjrd review_requested #3555
  • Jan 31 2019 22:56
    sjrd opened #3555
  • Jan 31 2019 21:06

    sjrd on 0.6.x

    Remove dead code: specific coll… Adapt the signature of `js.Arra… Merge pull request #3554 from s… (compare)

  • Jan 31 2019 21:06
    sjrd closed #3554
  • Jan 31 2019 20:54
    erikvanoosten commented #2665
  • Jan 31 2019 16:33
    sjrd commented #3538
  • Jan 31 2019 15:54

    sjrd on master

    Fix analyzer cycle detection to… Add toString methods to analyze… Do not provide linked ClassInfo… and 1 more (compare)

  • Jan 31 2019 15:54
    sjrd closed #3552
  • Jan 31 2019 15:54

    sjrd on master

    Remove Logger.success It is un… Make level helpers final Clean-up ScalaConsoleLogger cod… and 1 more (compare)

  • Jan 31 2019 15:54
    sjrd closed #3553
jhegedus42
@jhegedus42
also
things
are a bit shadowy
why e
why not e1 ?
what is they type of HTMLElement ?
is it a type or a value ?
anyway
is there any nice example on how to upload a file to a webserver ?
an image
for example ?
       <.div(
          titleS.component(),
          button.getVDOM(),
          "For debug:",
          <.br,
          <.pre(HelperPrint.prettyPrint(e2)),
          <.button("upload",^.`type`:="file",^.onClick-->Callback(println("upload clicked")))
        )
i am the one who is writing the web server too
so... i can create any sort of event handler
Øyvind Raddum Berg
@oyvindberg
@dportabella I think that code should have worked. Try to say e.target.asInstanceOf[js.Dynamic].nodeName to see what you actually get
David Portabella
@dportabella

I've modified the example with your comments:

package tutorial.webapp

import org.scalajs.dom._
import org.scalajs.dom.raw._
import scala.scalajs.js

object TutorialApp {
  def main(args: Array[String]): Unit = {
    window.document.body.innerHTML = "<p><b>main window</b></p>"

    val iframe = document.createElement("iframe")
    document.body.appendChild(iframe)
    val iframeWindow = iframe.asInstanceOf[HTMLIFrameElement].contentWindow
    iframeWindow.document.body.innerHTML = "<p><b>iframe</b></p>"


    window.document.addEventListener("click", clicked)        
    // this works as expected:
    // clicking on the 'main window' text, produces this console log:
    // - clicked an HTMLElement B
    // - parent is an HTMLParagraphElement P


    iframeWindow.document.addEventListener("click", clicked)  // this doesn't
    // this does not work as expected:
    // clicking on the 'iframe' text, produces this console log:
    // - clicked an EventTarget B
    // - parent is an HTMLElement P
  }

  def clicked(mouseEvent: MouseEvent) {
    mouseEvent.target match {
      case e: HTMLElement => console.log("clicked an HTMLElement", e.asInstanceOf[HTMLElement].tagName)
      case e: EventTarget => console.log("clicked an EventTarget", e.asInstanceOf[HTMLElement].tagName)
    }

    val parent = mouseEvent.target.asInstanceOf[HTMLParagraphElement].parentElement
    parent match {
      case e: HTMLParagraphElement => console.log("parent is an HTMLParagraphElement", e.asInstanceOf[HTMLElement].tagName)
      case e: HTMLElement => console.log("parent is an HTMLElement", e.asInstanceOf[HTMLElement].tagName)
    }
  }
}

When I click inside the iframe on the <h1>iframe</h1>, I get an EventTarget instead of an HTMLElement. Casting it to HTMLElement works, but e.parentElement is an HTMLElement instead of HTMLParagraphElement.

Maybe the ScalaJs script adds some functionality to the window to cast the html nodes into ScalaJs classes, and this functionality is not loaded inside the iframe.
Any idea?

Øyvind Raddum Berg
@oyvindberg
Maybe DOM elements in iframes are different from what is loaded in the main document, I don't know. I would just cast instead of pattern patch
David Portabella
@dportabella
I cannot cast as I don't know what subtype of HTMLElement will be in advance (the example above was just an example to show the problem).
I guess pattern match on its tagName then
and then cast appropriately
David Portabella
@dportabella
@oyvindberg, If I understood the stackoverflow post correctly, this issue/problem has nothing to do with ScalaJs, right? the problem already arises in javascript, right?
Øyvind Raddum Berg
@oyvindberg
exactly
Iurii Malchenko
@yurique

hi everyone,
I can’t figure this thingy, maybe someone can help me :)

I want to make a facade for a simple js lib that exports a function, so in js I would write

import exportedFunction from “somewhere”

const result = exportedFunction();

and I’m confused about how to express this with @JSImport

Iurii Malchenko
@yurique
found this: scala-js/scala-js#3603
trying it out
Brian Kent
@bdkent
are there any hooks into the ScalaJS compilation to perform an arbitrary action per @JSExportTopLevel / @JSExport / etc ?
Sébastien Doeraene
@sjrd
What kind of action?
You can hook in your own linker frontend or backend, that will intercepted either the entering raw IR, or the optimized IR, respectively.
See for example https://github.com/scala-js/scala-js/blob/49ef067c1c304a77a7a5398cf5de8e6325279497/linker/shared/src/test/scala/org/scalajs/linker/OptimizerTest.scala#L191 which is a test that hooks in a custom backend to test that the optimizer does its job as expected.
Li Haoyi
@lihaoyi
could probably write a compiler plugin too?
if you don't mind hooking in at the compiler frontend
Zak Patterson
@zakpatterson
I'm having challenges accessing headers in returned XMLHttpRequests in the node environment. I started up a branch with a failing test here: zakpatterson/scala-js-dom@80d5473 I thought I'd poll the room before creating an issue or wip PR for this
oddly the response completes and the response text is available, as you can see in the first passing test, but the responseHeaders are still set to the request header values.
Zak Patterson
@zakpatterson
AH nevermind this was just me not understanding how cors headers work
Eric K Richardson
@ekrich
Is there a time frame for a 0.6.30 release?
Sébastien Doeraene
@sjrd
Normally around 2 months after 0.6.29, so towards 15-20 November.
Eric K Richardson
@ekrich
Ok, cool thanks for the info!
aappddeevv
@aappddeevv
Is there a way to passthru a comment when using js.import? webpack bundlers expected hints for imports in the form js.import(/* webpackChunkName: lodash */ "lodash"). I checked the output and the comment was dropped in the js of course. I need to be able to bundle with webpack. I could easily reduce bundle size for some large 3rd-party components this way.
Sébastien Doeraene
@sjrd
There is no way, and there won't be a way. This is pure evil that is not supported by the spec. You can complain to webpack that they should provide a different API for that because it is 100% incompatible with any pre-webpack compiler.
aappddeevv
@aappddeevv
Well...given that change is a journey, I guess sed is my short-term friend here :-) I opened a webpack ticket.
Sébastien Doeraene
@sjrd
:+1:
aappddeevv
@aappddeevv
alright, report back...used string-replace-loader in webpack and ensured my chunk optmizations were not weird. Result was that dynamic import worked well and I was able to separate out a very large library needed for just a single view. Makes a big difference.
Dan Di Spaltro
@dispalt
@sjrd is there a way to convert a throwable to something that error reporters would like (like sentry), there seems to be a lot of code to display them nicely, so chrome makes it clickable, but I guess I am thinking more that they're an instance of js.Error or something
Sébastien Doeraene
@sjrd
@dispalt Yes: you can use Scala.js 1.x, in which Throwable is a subclass of JavaScript's Error at run-time.
Dan Di Spaltro
@dispalt
oh interesting, thanks! val err = new js.Error(e.getMessage); err.asInstanceOf[js.Dynamic].stack = e.stack kinda works in the interim
Iurii Malchenko
@yurique

I’m sending a post request with XMLHttpRequest and FormData, but the browser doesn’t set the Content-Type: multipart/form-data; boundary=… content-type and doesn’t display the request as multipart in dev tools and the server (s3) rejects the request
maybe someone knows what I might be doing wrong here?

I see there are calls to fromString (to js.Any) before passing params to FormData#append and I had an implicit conversion from T: Encoder to Ajax.InputData which sneaked in instead of fromString, which was surprising and broke things, too; but it’s no longer the case.
I’ve had this code working (now updating and refactoring), and this part looks the same (though the scalajs version changed .20 -> .29)

(ah, the browser actually sets content type to son, now to find “why?" :) )
Iurii Malchenko
@yurique
uh oh, me is actually blind (and stupid :/) - I’m adding the content type manually
Yura Slinkin
@augustjune
Hi guys, I am a newcomer to ScalaJs.
How do you do logging of the events on the client side? Do you usually use some logging libraries or just print the events to the console?