Coder Social home page Coder Social logo

Full SVG support about dom-chef HOT 5 CLOSED

fregante avatar fregante commented on September 26, 2024 1
Full SVG support

from dom-chef.

Comments (5)

vadimdemedes avatar vadimdemedes commented on September 26, 2024

This uncovers an issue: all the tags in <iframe></iframe> should be created with the SVG namespace

Thanks for bringing this up!

The problem is h is invoked for the most nested elements first, going from the bottom of the tree upwards. That's why we can't do what Preact does, encounter <svg> element and enable isSVG, which would use SVG namespace for all children.

Not sure right now how to work around this.

from dom-chef.

vadimdemedes avatar vadimdemedes commented on September 26, 2024

Until there's a solution, dom-chef could use svg-tag-names and just exclude tags that are also html tags, like iframe and a. It wouldn't count as full SVG support, but still better than nothing.

from dom-chef.

vadimdemedes avatar vadimdemedes commented on September 26, 2024

Added more tags using svg-tag-names module via e2f07ae.

from dom-chef.

pygy avatar pygy commented on September 26, 2024

A solution would to have h create a vDOM tree as an IR, with a wrapper function called to materialize the DOM.

const el = domify(<svg><iframe></iframe></svg>);

where domify() propagates the NS from the root to the leafs.

from dom-chef.

fregante avatar fregante commented on September 26, 2024

I don't think this can be further resolved and probably it's fine. <iframe> works even without the SVG namespace.

Since babel-plugin-transform-react-jsx creates nested calls, h('iframe') won't know it's a child of h('svg') until the latter is created, and we can't safely correct the NS of the iframe once that happens.

The only way to support this would be by changing the babel transform to something that can be parsed at once, like JSX-IR, but really at that point it's best to just go with #7 (comment)

React either ignores this issue or is able to correct the NS before actually generating the dom because it has total control over it.

from dom-chef.

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.