Coder Social home page Coder Social logo

Comments (2)

asg017 avatar asg017 commented on May 26, 2024

Hey @nicola , thanks for the bug report!

Dataflow uses htl for the html and svg builtins. These html and svg alternatives, which are slightly different than the current defaults on observablehq.com, offer more functionality and features and are better all around, imo (and observablehq plans to make them the default in the future).

But, that means that when you try to import notebooks that use the old html and svg variants, there may be some bugs. The @jashkenas/inputs notebook is one of these problematic notebooks, it uses the old html builtin that's not compatible with the new htl.html equivalent. You can see this if you go to that notebook and add this as a new cell:

html = (await require("htl")).html

You'll see that several of the inputs will error out with invalid binding, and you see in your example.

To fix this in dataflow, you have a few options. One option, you can fetch a copy of the old html builtin from the @observablehq/stdlib standard library, and substitute that value in when you import:

oldHtml = new (await require("@observablehq/stdlib")).Library().html();


import { select } with {oldHtml as html} from "https://observablehq.com/@jashkenas/inputs";

select(["a", "b"]);

image

Or, you can fork that notebook, update it to use htl.html, and import that notebook instead. Although that notebook is a little complicated under the hood, so it could take some time.

Or, if you don't like the htl default for html and svg in dataflow, you can use the custom stdlib feature to override this behavior and substitute the older html and svg builtins instead. This is also a little more complicated, because the custom stdlib feature is a little awkward right now and it won't work with dataflow compile just yet, but if you have a custom_stdlib.js file like this:

window.OJS_STDLIB = {
  dependency: {
    require: {
      html: (require) => require("@observablehq/stdlib").then( lib => new lib.Library().html() )
    }
  }
};

And your notebook.ojs file looks like this:

import { select } from "https://observablehq.com/@jashkenas/inputs";

select(["a", "b"]);

Then running the notebook with dataflow run notebook.ojs --stdlib custom_stdlib.js will run the notebook with the older html builtin, and the notebook will run as expected.

Also, I'd suggest using @observablehq/inputs iff possible instead of @jashkenas/inputs, since it bundles it's own dependencies in it's own library, and it plays well with dataflow right out of the box!

from dataflow.

nicola avatar nicola commented on May 26, 2024

Makes a lot of sense, thank you!

from dataflow.

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.