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

Fix inputs values. #123

Merged
merged 4 commits into from
Jan 20, 2017
Merged

Conversation

tomasztomys
Copy link
Contributor

@clauderic
Copy link
Owner

clauderic commented Jan 20, 2017

Hey @tomasztomys, thanks for submitting this 😄

I slightly altered your implementation of the pre-population logic to account for cases where the select/textarea/input wouldn't have a name attribute. Instead, I'm simply running the same querySelectorAll query against the cloned node, which returns the elements in the same order as the first query, and therefore makes it easy to simply map the values from one to the other via their index.

🚢 LGTM

@clauderic clauderic merged commit 5a40af7 into clauderic:master Jan 20, 2017
@tomasztomys tomasztomys deleted the fix-input-values branch January 20, 2017 09:24
@tomasztomys
Copy link
Contributor Author

Are you sure that all nodes in cloned node will have the same order in each situation? Find by name is safer

@clauderic
Copy link
Owner

clauderic commented Jan 30, 2017

From http://www.w3.org/TR/selectors-api/#queryselectorall, the nodes will always be returned in document order (which will remain the same even if the element is cloned):

The querySelectorAll() method on the NodeSelector interface must, when invoked, return a NodeList containing all of the matching Element nodes within the node’s subtrees, in document order.

I think find by name would only be reliable assuming the inputs were indeed named.

DimitarNestorov pushed a commit to codemotionapps/react-sortable-hoc that referenced this pull request Feb 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants