-
-
Notifications
You must be signed in to change notification settings - Fork 904
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
Add DOM-compatible method insert_before
#664
Comments
FWIW, I've repeatedly been surprised that Nokogiri's method names do not match (or alias) the DOM methods. I totally appreciate the convenience of things like |
@Phrogz - Thanks for suggesting this! It's clearly a hole in Nokogiri's API that we'll fill. Nokogiri was never intended to be a 1-to-1 DOM mapping. There's a reason why we ripped off hpricot's API and not the W3C committee's API. And it's the same reason that jQuery exists: http://en.wikipedia.org/wiki/Design_by_committee I mean, How about this method instead:
or maybe an option on the existing method like:
|
Both of your suggestions look good. If I had to pick one over the other I'd personally lean towards the first one, though both would be nice. Even nicer, though, would be to modify
While the DOM bindings are admittedly weird and often inconvenient, I find that having the ability to specify an anchor element or deleted a use case that did not, in fact, make sense |
If you want to insert a node as the first child of another you currently have to write code like:
If Nokogiri added a
Nokogiri::XML::Node#insert_before
method like the DOM 2 Core methodNode.prototype.insertBefore()
then the above code would be far simpler and DRY:The text was updated successfully, but these errors were encountered: