Skip to content
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

searching for a element with a specific id in a element stored in a js variable returns null if the id is in the page dom #56

Open
deos opened this issue Sep 28, 2011 · 1 comment
Assignees
Labels

Comments

@deos
Copy link

deos commented Sep 28, 2011

im not sure if this is a bug in mootools core or slick, but i think it belongs here

when creating a element that is stored in a js variable and is not in the page dom and i try to search in it (with getElement) for a id that is used there AND in the page dom then the search returns null

ive got the problem with an project im using ajax in. on requesting a page i get html with elements like #navi as result but as there is a #navi on the main page i cant access the navi from the ajax result

example: http://jsfiddle.net/Pqq6t/

  • crated a element with a bit html in it: 2 p-elements with the ids "test" and "test2"
  • searching in the element for the first one "test" (the id is not in the page dom): returns the element
  • seraching in the element for the second one "test2" (the id is already used in the page dom): returns null

im expecting the second element to get returned even if it has the same id that is already used in the dom because the element itself is not in the dom

@fabiomcosta
Copy link
Member

Hi deos, Thank you for your report! Sorry for taking so long to respond.

Looks like this happens because before selecting element using querySelectorAll we define the context as the parentNode of the current context, so selectors like + some and ~ some, which will select elements that are not inside the context, will work. What I'm gonna do is, I'll just set the context as the parentNode if the selector is one of those.

Thank you!

@ghost ghost assigned fabiomcosta Mar 12, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants