-
Notifications
You must be signed in to change notification settings - Fork 264
Update position.xml #592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update position.xml #592
Conversation
Clarify documentation to explicitly specify position() is not supported on text elements.
Very few jQuery APIs support text nodes, since it's relatively difficult to even get a text node into a collection. What did the code look like that prompted this docs clarification? |
@dmethvin The code was related to identifying the position of a word in a text selection (bounded within a I was struck by the lack of information about it in the jquery documentation, and thought it should be clearer to developers that only Elements are supported. |
How did you get the text node into a jQuery object to ask for its position? You'd do something akin to The default assumption should be that jQuery operations on text nodes are not supported. They're not supported by There already is this note in the jQuery entry, maybe we can clarify things there?
|
Ah, how about if we clarify that the |
@arthurvr CLA signed. Thx. |
Is this PR good to be merged? On a side note, I think @dmethvin note could be added. |
@@ -9,7 +9,7 @@ | |||
<p>The <code>.position()</code> method allows us to retrieve the current position of an element <em>relative to the offset parent</em>. Contrast this with <code><a href="/offset/">.offset()</a></code>, which retrieves the current position <em>relative to the document</em>. When positioning a new element near another one and within the same containing DOM element, <code>.position()</code> is the more useful.</p> | |||
<p>Returns an object containing the properties <code>top</code> and <code>left</code>.</p> | |||
<div class="warning"> | |||
<p><strong>Note:</strong> jQuery does not support getting the position coordinates of hidden elements or accounting for borders, margins, or padding set on the body element.</p> | |||
<p><strong>Note:</strong> jQuery does not support getting the position coordinates of hidden elements or accounting for borders, margins, or padding set on the body element. Position coordinates are not supported for node types other than Element.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two spaces before the word Position
.
Do we really need a note on all these page (as seen in this PR)? I don't think so. IMHO a paragraph on the "using dom elements" article is enough:
If everybody agrees with that, we should open a decent ticket for that page and close this PR. |
@dmethvin @AurelioDeRosa Thoughts? I don't think having an explicit note on many of our pages makes sense, if the default assumption should be it isn't supported. |
Agreed, @arthurvr. Let's improve the messaging on We never got a reply from @pcj on how the text node ended up in the collection, but if we do we could try to address that usage as well. |
Clarify documentation to explicitly specify position() is not supported on text elements.