Skip to content

Commit ee3364c

Browse files
committedMar 26, 2015
Add Element#prepend
1 parent 6d864fb commit ee3364c

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed
 

Diff for: ‎CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## EDGE
22

3+
* Add `Element#prepend` method.
4+
35
## 0.3.0 2015-02-03
46

57
* Move all files under `opal/jquery` require namespace, rather than

Diff for: ‎lib/opal/jquery/element.rb

+5
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,11 @@ def self.expose(*methods)
244244
# @param content [String, Element]
245245
alias_native :append
246246

247+
# @!method prepend(content)
248+
#
249+
# @param content [String, Element]
250+
alias_native :prepend
251+
247252
# @!method serialize
248253
alias_native :serialize
249254

Diff for: ‎spec/element/prepend_spec.rb

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
require 'spec_helper'
2+
3+
describe 'Element#prepend' do
4+
html <<-HTML
5+
<div id="foo"></div>
6+
<div id="bar">
7+
<p>Something</p>
8+
</div>
9+
HTML
10+
11+
it 'inserts the given html to beginning of element' do
12+
foo = Element.find '#foo'
13+
bar = Element.find '#bar'
14+
15+
foo.prepend '<span>Bore Da</span>'
16+
expect(foo.children.first.text).to eq 'Bore Da'
17+
18+
bar.prepend '<span>Charlie</span>'
19+
expect(bar.children.first.text).to eq 'Charlie'
20+
end
21+
end

0 commit comments

Comments
 (0)
Please sign in to comment.