Coder Social home page Coder Social logo

Invalid HTML from view! about sycamore HOT 6 CLOSED

smessmer avatar smessmer commented on May 20, 2024
Invalid HTML from view!

from sycamore.

Comments (6)

gbj avatar gbj commented on May 20, 2024 1

This is because <input> can’t have children, no? The position of the label and the input are reversed.

from sycamore.

lukechu10 avatar lukechu10 commented on May 20, 2024

This is quite puzzling. I'll look more into this.

from sycamore.

arctic-hen7 avatar arctic-hen7 commented on May 20, 2024

For reference, that error emanates from Perseus, and there's extensive documentation about it in our FAQs. This sort of HTML will be happily parsed by most browsers, but it's strictly invalid according to the spec. Having Sycamore prevent this is probably not the best idea, because sometimes you want spec-invalid HTML to do particularly wacky things (like links inside links, which do rarely have their uses if accessibility is properly handled).

from sycamore.

smessmer avatar smessmer commented on May 20, 2024

I don't mind whether Perseus/sycamore allows nesting labels inside of inputs or throws an error. But the current implementation does neither and instead seems to mangle the HTML. This looks like a buffer overflow or out-of-bounds write.

from sycamore.

lukechu10 avatar lukechu10 commented on May 20, 2024

This is not a memory related error but is instead the minifier choking on invalid HTML.
Given the following code:

view! { cx,
    input {
        label {
            "Foo"
        }
    }
}

Sycamore returns the following SSRed string:

<input data-hk="0.0"><label data-hk="0.1">Foo</label></input>

Perseus's minifier assumes that the only html it can receive is semantically valid HTML as described by the spec, allowing it to further shrink the resulting HTML. However, Sycamore allows arbitrary nesting of HTML elements, including invalid ones such as a label inside an input, which thereby causes problems such as these.

I'm going to close this issue now since it is not a Sycamore bug and I'm not even sure if it should even be considered as a Perseus bug since there is not much we can do about it besides disabling the minifier altogether.

from sycamore.

arctic-hen7 avatar arctic-hen7 commented on May 20, 2024

I agree with @lukechu10, but I'll also add that the Perseus minifier does mangle the output HTML deliberately, doing things like removing closing tags, because browsers can still interpret this, it just lessens the number of bytes needing to be transferred over the network. It's odd behaviour I agree, but it's intended. I would recommend disabling the minifier by turning off default features if you'd like to use technically invalid HTML like this.

from sycamore.

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.