Skip to content

Commit 3c657a0

Browse files
authored
Merge pull request #107 from opal/staging
18th Staging
2 parents 857f88d + dba2db2 commit 3c657a0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+232
-311
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
## 0.3.4
2+
* Element#children=
3+
* Support more methods on Media
4+
* Event::Custom to support non-enumerable properties
25
* DOM::Element::Form: #valid?, #request_submit, #ajax_submit
36
* Compatibility for Opal-RSpec 1.0
47

opal/browser/dom/element.rb

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# backtick_javascript: true
2+
13
# Requires are moved to the bottom of this file.
24

35
module Browser; module DOM
@@ -367,6 +369,8 @@ def inner_dom=(node)
367369
self << node
368370
end
369371

372+
alias children= inner_dom=
373+
370374
# @!attribute inner_html
371375
# @return [String] the inner HTML of the element
372376
def inner_html

opal/browser/dom/element/attributes.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# backtick_javascript: true
2+
13
module Browser; module DOM; class Element < Node
24

35
class Attributes

opal/browser/dom/element/button.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# backtick_javascript: true
2+
13
module Browser; module DOM; class Element < Node
24

35
class Button < Element

opal/browser/dom/element/custom.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# use_strict: true
22
# helpers: truthy
3+
# backtick_javascript: true
34

45
module Browser; module DOM; class Element < Node
56

@@ -174,4 +175,4 @@ def detached_once
174175
include Mixin
175176
end
176177

177-
end; end; end
178+
end; end; end

opal/browser/dom/element/data.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# backtick_javascript: true
2+
13
module Browser; module DOM; class Element < Node
24

35
class Data

opal/browser/dom/element/editable.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# backtick_javascript: true
2+
13
module Browser; module DOM
24

35
class Element < Node

opal/browser/dom/element/form.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# backtick_javascript: true
2+
13
module Browser; module DOM; class Element < Node
24

35
class Form < Element

opal/browser/dom/element/iframe.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# backtick_javascript: true
2+
13
module Browser; module DOM; class Element < Node
24

35
class Iframe < Element

opal/browser/dom/element/image.rb

+6-15
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,14 @@
1+
# backtick_javascript: true
2+
13
module Browser; module DOM; class Element < Node
24

35
class Image < Element
46
def_selector "img"
57

6-
def complete?
7-
`#@native.complete`
8-
end
9-
10-
def cross?
11-
`#@native.crossOrigin`
12-
end
13-
14-
def height
15-
`#@native.naturalHeight`
16-
end
17-
18-
def width
19-
`#@native.naturalWidth`
20-
end
8+
alias_native :complete?, :complete
9+
alias_native :cross?, :crossOrigin
10+
alias_native :height, :naturalHeight
11+
alias_native :width, :naturalWidth
2112
end
2213

2314
Img = Image

opal/browser/dom/element/input.rb

+7-19
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# backtick_javascript: true
2+
13
module Browser; module DOM; class Element < Node
24

35
class Input < Element
@@ -14,21 +16,11 @@ def value
1416
}
1517
end
1618

17-
def value=(value)
18-
`#@native.value = #{value}`
19-
end
20-
21-
def name_
22-
`#@native.name`
23-
end
24-
25-
def type
26-
`#@native.type`
27-
end
28-
29-
def checked?
30-
`#@native.checked`
31-
end
19+
alias_native :value=
20+
alias_native :name_, :name
21+
alias_native :type
22+
alias_native :checked?, :checked
23+
alias_native :enabled?, :enabled
3224

3325
def check!
3426
`#@native.checked = 'checked'`
@@ -38,10 +30,6 @@ def uncheck!
3830
`#@native.checked = ''`
3931
end
4032

41-
def enabled?
42-
`#@native.enabled`
43-
end
44-
4533
def disable!
4634
`#@native.disabled = 'disabled'`
4735
end

opal/browser/dom/element/media.rb

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
module Browser; module DOM; class Element < Node
22

33
class Media < Element
4-
def play
5-
`#@native.play()`
6-
end
4+
alias_native :play
5+
alias_native :pause
6+
alias_native :time, :currentTime
7+
alias_native :time=, :currentTime
78
end
89

910
class Video < Media

opal/browser/dom/element/offset.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# backtick_javascript: true
2+
13
module Browser; module DOM; class Element < Node
24

35
class Offset

opal/browser/dom/element/scroll.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# backtick_javascript: true
2+
13
module Browser; module DOM; class Element < Node
24

35
# @todo Consider using the new interfaces which allow for optional

opal/browser/dom/element/select.rb

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# backtick_javascript: true
2+
13
module Browser; module DOM; class Element < Node
24

35
class Select < Element
@@ -14,9 +16,7 @@ def value
1416
}
1517
end
1618

17-
def value= value
18-
`#@native.value = #{value.to_n}`
19-
end
19+
alias_native :value=
2020

2121
def labels
2222
NodeSet[Native::Array.new(`#@native.labels`)]
@@ -30,10 +30,7 @@ def option
3030
DOM(`#@native.options[#@native.selectedIndex]`)
3131
end
3232

33-
def index
34-
`#@native.selectedIndex`
35-
end
36-
33+
alias_native :index, :selectedIndex
3734
alias_native :multiple?, :multiple
3835
alias_native :required?, :required
3936
alias_native :length

opal/browser/dom/element/size.rb

+6-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
module Browser; module DOM; class Element < Node
22

33
class Size
4+
include Native::Wrapper
5+
46
attr_reader :element
57

68
# @private
@@ -12,35 +14,27 @@ def initialize(element, *inc)
1214

1315
# @!attribute width
1416
# @return [Integer] the element width
15-
def width
16-
`#@native.offsetWidth`
17-
end
17+
alias_native :width, :offsetWidth
1818

1919
def width=(value)
2020
@element.style[:width] = value
2121
end
2222

2323
# @!attribute height
2424
# @return [Integer] the element height
25-
def height
26-
`#@native.offsetHeight`
27-
end
25+
alias_native :height, :offsetHeight
2826

2927
def height=(value)
3028
@element.style[:height] = value
3129
end
3230

3331
# @!attribute client_width
3432
# @return [Integer] the content-box width of an element
35-
def client_width
36-
`#@native.clientWidth`
37-
end
33+
alias_native :client_width, :clientWidth
3834

3935
# @!attribute client_height
4036
# @return [Integer] the content-box height of an element
41-
def client_height
42-
`#@native.clientHeight`
43-
end
37+
alias_native :client_height, :clientHeight
4438
end
4539

4640
end; end; end

opal/browser/dom/element/template.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# backtick_javascript: true
2+
13
module Browser; module DOM; class Element < Node
24

35
class Template < Element

opal/browser/dom/element/textarea.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# backtick_javascript: true
2+
13
module Browser; module DOM; class Element < Node
24

35
class Textarea < Element
@@ -14,9 +16,7 @@ def value
1416
}
1517
end
1618

17-
def value=(value)
18-
`#@native.value = #{value}`
19-
end
19+
alias_native :value=
2020

2121
def clear
2222
`#@native.value = ''`

opal/browser/event/animation.rb

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# backtick_javascript: true
2+
13
module Browser; class Event
24

35
class Animation < Event
@@ -8,13 +10,9 @@ def self.supported?
810
end
911

1012
class Definition < Definition
11-
def animation=(value)
12-
`#@native.animationName = #{value}`
13-
end
14-
15-
def elapsed=(value)
16-
`#@native.elapsedTime = #{value}`
17-
end
13+
alias_native :name=, :animationName=
14+
alias_native :animation=, :animationName=
15+
alias_native :elapsed=, :elapsedTime=
1816
end
1917

2018
if Browser.supports? 'Event.constructor'

opal/browser/event/audio_processing.rb

+5-11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# backtick_javascript: true
2+
13
module Browser; class Event
24

35
class AudioProcessing < Event
@@ -8,17 +10,9 @@ def self.supported?
810
end
911

1012
class Definition < Definition
11-
def time=(value)
12-
`#@native.playbackTime = #{value}`
13-
end
14-
15-
def input=(value)
16-
`#@native.inputBuffer = #{value}`
17-
end
18-
19-
def output=(value)
20-
`#@native.outputBuffer = #{value}`
21-
end
13+
alias_native :time=, :playbackTime=
14+
alias_native :input=, :inputBuffer=
15+
alias_native :output=, :outputBuffer=
2216
end
2317

2418
if Browser.supports? 'Event.constructor'

opal/browser/event/base.rb

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# backtick_javascript: true
2+
13
module Browser
24

35
class Event
@@ -16,14 +18,10 @@ def self.new(&block)
1618
end
1719

1820
# Set the event as bubbling.
19-
def bubbles=(value)
20-
`#@native.bubbles = #{value}`
21-
end
21+
alias_native :bubbles=
2222

2323
# Set the event as cancelable.
24-
def cancelable=(value)
25-
`#@native.cancelable = #{value}`
26-
end
24+
alias_native :cancelable=
2725
end
2826

2927
module Target

opal/browser/event/before_unload.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# backtick_javascript: true
2+
13
module Browser; class Event
24

35
class BeforeUnload < Event

opal/browser/event/clipboard.rb

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# backtick_javascript: true
2+
13
module Browser; class Event
24

35
class Clipboard < Event
@@ -8,13 +10,8 @@ def self.supported?
810
end
911

1012
class Definition < Definition
11-
def data=(value)
12-
`#@native.data = #{value}`
13-
end
14-
15-
def type=(value)
16-
`#@native.dataType = #{value}`
17-
end
13+
alias_native :data=
14+
alias_native :type=, :dataType=
1815
end
1916

2017
if Browser.supports? 'Event.constructor'

opal/browser/event/close.rb

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# backtick_javascript: true
2+
13
module Browser; class Event
24

35
class Close < Event
@@ -8,13 +10,8 @@ def self.supported?
810
end
911

1012
class Definition < Definition
11-
def code=(value)
12-
`#@native.code = #{value}`
13-
end
14-
15-
def reason=(value)
16-
`#@native.reason = #{value}`
17-
end
13+
alias_native :code=
14+
alias_native :reason=
1815

1916
def clean!(value)
2017
`#@native.wasClean = true`

0 commit comments

Comments
 (0)