Hacker News new | ask | show | jobs
by liamondrop 4621 days ago
Not to detract from the creativity here, but the id attribute specifies its element's unique identifier[1]. Strictly speaking, this should never happen:

  <div id="b7">
    <div id="b71">
      <div id="b71">
        <div id="b71">
          <div id="b71">
            ...
[1] http://www.w3.org/TR/2013/WD-html51-20130528/dom.html#the-id...
3 comments

"strictly speaking" is right. It's invalid but all major browsers will handle the code just fine. Browsers are pretty damn forgiving.

It's also an easy mistake to make. All someone has to do is create an element with an ID in a child template without checking to see if that ID is already used in a parent template.

Is it possible to enable some switch in Chrome to force the browser to render only correct code in dev mode? This would catch me making mistakes that otherwise go unnoticed.

On the note of forgiving browsers, I love how they are a very accepting interpreter of information, much like a human listening to someone's broken English and still understanding what is being said.

Right after seeing Bender dance, that was the very first thing I noticed as well.
Yeah, not sure why it's not throwing a bunch of jQuery errors in the console
I don't think any Javascript is in use at all here, but if it were I would not expect errors but instead simply unexpected behaviour as browsers tend to just try do something if what you are asking isn't clear (for instance if a jquery selector returns nothing, any changes you chain after the call just apply to that nothing instead of complaining that they expect to have some nodes to act on).

Multiple elements with the same ID is wrong of course, so you can't guarantee what will happen if you use and ID based selector: three equally (in)correct interpretations would be "act on the first element you find with that ID", "act on all elements with that ID", and "error because we don't expect to find more than one". By breaking the standard you are exposing yourself to undefined behaviour - the browser can do what it likes and each environment might do something different.

I don't see any jQuery or even JavaScript being used.
> Pure CSS3