Giter VIP home page Giter VIP logo

Comments (4)

stewSquared avatar stewSquared commented on July 17, 2024

Note that this is a one line change in each of https://github.com/lihaoyi/scalatags/blob/master/scalatags/js/src/main/scala/scalatags/JsDom.scala#L43 and https://github.com/lihaoyi/scalatags/blob/master/scalatags/shared/src/main/scala/scalatags/Text.scala#L38. I'll be happy to make the pull request adding with jsdom.Tags to object short. I just wanted to make sure we agree this is a bug.

To explain a bit more clearly why I think this is appropriate:

This compiles:

import scalatags.JsDom.all._
div(width:=10.px, List(p,p))

But you might not want all the styles and attributes polluting your namespaces, so short is provided. The div above would become div(*.width:=10.px, List(p,p)). However, contrary to the docs, this doesn't compile:

import scalatags.JsDom.short._
div(*.width:=10.px, List(p,p))

You could add import scalatags.JsDom.tags._, and it will still fail to compile.

It will compile if you import short.*; all._, or short._; tags.{p,div} but those are undesirable for obvious reasons. So you might decide to try:

scalatags.JsDom.short.*
scalatags.JsDom.tags._
div(*.width:=10.px, List(p,p))

That compiles - yay! But other things will break unless you also import:

import scalatags.JsDom.short.{bindJsAny,bindJsAnyLike,bindNode}
import scalatags.JsDom.implicits._
import scalatags.DataConverters._

and probably a bunch of other things that I'm missing and aren't meant to be part of the public API.

Same is true if you replace all occurences of JsDom with Text. In the case where you try to import text._ with short._, compile errors won't show up in the REPL unless you wrap all of those lines in an object{...}.

TL;DR

As per the docs, I want to write div(*.width:=10.px, List(p,p)) and can't without hideous imports. It's a two-line fix if we agree it's a bug.

from scalatags.

stewSquared avatar stewSquared commented on July 17, 2024

So, after a bit more digging, I've found a bug in the tests for manual Imports. which is that import bundle.all._ is in scope, which kinda defeats the point of manual imports. I'll tweak the tests and offer a PR.

from scalatags.

lihaoyi avatar lihaoyi commented on July 17, 2024

Thanks for digging into this @stewSquared!!!

from scalatags.

lihaoyi avatar lihaoyi commented on July 17, 2024

Your fix has been merged

from scalatags.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.