Giter VIP home page Giter VIP logo

Comments (8)

dmethvin avatar dmethvin commented on May 22, 2024

Our HTML parser is the browser's parser. Does it act differently, for example throw an exception, when you do not use jQuery and instead use direct DOM operations?

from jquery.

ShadSterling avatar ShadSterling commented on May 22, 2024

I'm not familiar with the direct DOM operations, what would be equivalent? Using document.getElementById("someid").innerHTML = htmlString, it does not act differently in Firefox, Chromium, Safari, or Opera; see http://jsbin.com/hobuze/edit?html,console,output

If this is a browser bug, why is it the same in multiple browsers?

from jquery.

dmethvin avatar dmethvin commented on May 22, 2024

Yes, that is the equivalent operation, and the two behave similarly. No browser attempts to give an error, they just try to make sense of what you have given them. which may involve ignoring some of the input. See this article.

from jquery.

ShadSterling avatar ShadSterling commented on May 22, 2024

I understand dropping some of the input, but preventing developers from seeing the problem is an impediment to debugging. If the browsers fix the bug in their innerHTML= implementations, will that also generate the warning on .html()?

https://bugzilla.mozilla.org/show_bug.cgi?id=1085368
https://code.google.com/p/chromium/issues/detail?id=425101
https://bugs.webkit.org/show_bug.cgi?id=137881

from jquery.

dmethvin avatar dmethvin commented on May 22, 2024

Per the article, HTML5 parsing is lenient by design. A browser can give something like a console warning, but jQuery doesn't get involved in that process--you would need to look at the console.. IE10 and IE11 already do this for many static HTML errors on page, but don't give errors on HTML injection via .innerHTML.
capture

from jquery.

ShadSterling avatar ShadSterling commented on May 22, 2024

A console warning is exactly what I think is missing.

from jquery.

mgol avatar mgol commented on May 22, 2024

@Polyergic I don't think it's jQuery's job to provide console warnings for such things; browsers would have it easy to implement them today and they're not doing it on purpose; otherwise devs would get flooded with warnings.

jQuery's .html() setter internally sets the value of innerHTML so if a browser generates the warning, using jQuery will do it too. If we claimed we know better than browser vendors and there should be warnings about that, if a browser implements its own warnings you'd get a duplicate.

We're doing a right thing by not logging anything here by ourselves.

from jquery.

ShadSterling avatar ShadSterling commented on May 22, 2024

... which is why I submitted bugs to the browsers...

from jquery.

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.