Skip to main content

Search and Top Navigation

#9300 closed bug (notabug)

Opened May 15, 2013 12:10AM UTC

Closed May 15, 2013 12:51AM UTC

Last modified May 15, 2013 03:54PM UTC

Draggable element after body re-appended to parent on drag start

Reported by: jaredjacobs Owned by:
Priority: minor Milestone: none
Component: ui.draggable Version: 1.10.3
Keywords: Cc:
Blocked by: Blocking:
Description

A draggable element that is a direct child of the <html> element (not in the <body>) and that has no drag helper gets re-appended to its parent, making it the last child, when a drag begins.

http://jsfiddle.net/KZFNK/

One could argue that draggable elements should always be descendants of <body>, but in practice, browsers render elements after the body, and it's sometime useful to inject content into a page as direct children of <html> (e.g. in a browser extension). Doing so allows a Chrome or Firefox extension to add content to a <frameset> document (which has no <body>), for example.

Attachments (0)
Change History (7)

Changed May 15, 2013 12:22AM UTC by jaredjacobs comment:1

Pull request with one-line fix: https://github.com/jquery/jquery-ui/pull/987

Changed May 15, 2013 12:51AM UTC by scottgonzalez comment:2

resolution: → notabug
status: newclosed

Whether you find this useful or not, it's invalid HTML.

Changed May 15, 2013 04:20AM UTC by jaredjacobs comment:3

Hi Scott. Thanks for taking the time to evaluate this issue.

You're correct, of course, that content after the <body> is not valid HTML. Still, I'd ask you to please take a look at my tiny pull request (+4 bytes, -4 bytes). It doesn't introduce any code to the jQuery UI library that generates invalid HTML. It doesn't break the draggable library for any valid HTML documents. What's the harm, exactly?

Feel free to leave this ticket closed as notabug. I'm not claiming that there is a fault or defect in the library. I do believe, however, that pull request 987 will make jQuery UI more broadly useful. (I'm not aware of a jQuery team mandate to force HTML conformance on its users. It generally treats that as a user responsibility.)

Please take a moment to look at the pull request and respond to it either here or there. Thanks!

Changed May 15, 2013 12:19PM UTC by scottgonzalez comment:4

_comment0: > What's the harm, exactly? \ \ The harm is unbelievably large. Someone needs to write the code. Someone needs to review the code. Someone needs to write tests to verify the behavior. Everyone needs to ensure that we never regress. Having a test menas we're encouraging bad practices. Multiply this by the millions of invalid things people do all the time. That's a LOT of time and energy wasted on invalid use cases. \ \ > Please take a moment to look at the pull request and respond to it either here or there. \ \ This is part of the harm. I've already spent too much time discussing something that you know is invalid.1368620505266831
What's the harm, exactly?

The harm is unbelievably large. Someone needs to write the code. Someone needs to review the code. Someone needs to write tests to verify the behavior. Everyone needs to ensure that we never regress. Having a test means we're encouraging bad practices. Multiply this by the millions of invalid things people do all the time. That's a LOT of time and energy wasted on invalid use cases. Not to mention all the bytes that add up over time, purely for invalid edge cases.

Please take a moment to look at the pull request and respond to it either here or there.

This is part of the harm. I've already spent too much time discussing something that you know is invalid.

Changed May 15, 2013 01:19PM UTC by jaredjacobs comment:5

_comment0: You and I agree that the relevant HTML is non-conforming. However, I don't agree that the use case is invalid. There's a difference. Users often want to do things to documents written by one author using third-party scripts written by a different author. The third-party script authors don't have control over the global structure of the HTML document. Users don't care; they just want the third-party script to work. \ \ Take a look at the list of "intended scenarios" for using jQuery 2.0 (under '''How to Use It''' at http://blog.jquery.com/2013/04/18/jquery-2-0-released/). Browser extensions and add-ons are clearly listed. They are third-party script scenarios. \ \ You're in charge. If you'd like me to add a test to my pull request, I'd be happy to. If you just want me to go away, well, I can do that too. And if you're finding working on jQuery too demanding or stressful, well... it might be time to consider something new. http://www.42go.com/join_us.html Cheers!1368624497030705

You and I agree that the relevant HTML is non-conforming. However, I don't agree that the use case is invalid. There's a difference. Users often want to do things to documents written by one author using third-party scripts written by a different author. The third-party script authors don't have control over the global structure of the HTML document. Users don't care; they just want the third-party script to work.

Take a look at the list of "intended scenarios" for using jQuery 2.0 (under How to Use It at http://blog.jquery.com/2013/04/18/jquery-2-0-released/). Note that browser extensions and add-ons are listed. They are third-party script scenarios.

You're in charge. If you'd like me to add a test to my pull request, I'd be happy to. If you just want me to go away, well, I can do that too. And if you're finding working on jQuery too demanding or stressful, well... it might be time for a vacation or to consider something new. http://www.42go.com/join_us.html Cheers!

Changed May 15, 2013 01:58PM UTC by dmethvin comment:6

Hey Jared, I wrote that blog post and can assure you that making invalid code/markup work is not anywhere in the jQuery 2.0 charter. Perhaps you can use jQuery to correct the document, for example to move the markup into the body. But as Scott says, we've already spent too much time on this.

Also, say "hi" to Greg.

Changed May 15, 2013 03:54PM UTC by jaredjacobs comment:7

Can't change a <frameset> to a <body> with script, unfortunately, but thanks for taking the time to reply.