kupriyanenko / jbone

JavaScript Library for Events and DOM manipulation. Replaces jQuery for Backbone (2.5kb gzipped)
http://jbone.js.org
MIT License
279 stars 35 forks source link

adding a new method 'replaceWith' #17

Closed Tolia closed 10 years ago

Tolia commented 10 years ago

Did by analogy jquery

The .replaceWith() method removes content from the DOM and inserts new content in its place with a single call. Consider this DOM structure:

<nav>
  <a class="first" href="#first">first</a>
  <a class="second" href="#second">second</a>
</nav>

The second element could be replaced with new element

newEl = jBone('<b>second<b>')
jBone('.second').replaceWith(newEl)

This results in the structure:

<nav>
  <a class="first" href="#first">first</a>
  <b>second<b>
</nav>

replaceWith works with jBone and with DOM elements

makc commented 10 years ago

I watch this repo for a week or so, and majority of issues/pulls seem to be "please add X". Isn't that what jquery is for? It already has everything.

kupriyanenko commented 10 years ago

@Tolia I can merge this pull request only in extend branch, because jBone primarily not replacement for jQuery.

Like hotfix you can include this code in your own project, and it will working.

Tolia commented 10 years ago

@kupriyanenko ok, I redid https://github.com/kupriyanenko/jbone/pull/19