Skip to content

Commit

Permalink
Merge pull request #107 from opal/staging
Browse files Browse the repository at this point in the history
18th Staging
  • Loading branch information
hmdne authored Nov 24, 2023
2 parents 857f88d + dba2db2 commit 3c657a0
Show file tree
Hide file tree
Showing 48 changed files with 232 additions and 311 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
## 0.3.4
* Element#children=
* Support more methods on Media
* Event::Custom to support non-enumerable properties
* DOM::Element::Form: #valid?, #request_submit, #ajax_submit
* Compatibility for Opal-RSpec 1.0

Expand Down
4 changes: 4 additions & 0 deletions opal/browser/dom/element.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# backtick_javascript: true

# Requires are moved to the bottom of this file.

module Browser; module DOM
Expand Down Expand Up @@ -367,6 +369,8 @@ def inner_dom=(node)
self << node
end

alias children= inner_dom=

# @!attribute inner_html
# @return [String] the inner HTML of the element
def inner_html
Expand Down
2 changes: 2 additions & 0 deletions opal/browser/dom/element/attributes.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# backtick_javascript: true

module Browser; module DOM; class Element < Node

class Attributes
Expand Down
2 changes: 2 additions & 0 deletions opal/browser/dom/element/button.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# backtick_javascript: true

module Browser; module DOM; class Element < Node

class Button < Element
Expand Down
3 changes: 2 additions & 1 deletion opal/browser/dom/element/custom.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# use_strict: true
# helpers: truthy
# backtick_javascript: true

module Browser; module DOM; class Element < Node

Expand Down Expand Up @@ -174,4 +175,4 @@ def detached_once
include Mixin
end

end; end; end
end; end; end
2 changes: 2 additions & 0 deletions opal/browser/dom/element/data.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# backtick_javascript: true

module Browser; module DOM; class Element < Node

class Data
Expand Down
2 changes: 2 additions & 0 deletions opal/browser/dom/element/editable.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# backtick_javascript: true

module Browser; module DOM

class Element < Node
Expand Down
2 changes: 2 additions & 0 deletions opal/browser/dom/element/form.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# backtick_javascript: true

module Browser; module DOM; class Element < Node

class Form < Element
Expand Down
2 changes: 2 additions & 0 deletions opal/browser/dom/element/iframe.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# backtick_javascript: true

module Browser; module DOM; class Element < Node

class Iframe < Element
Expand Down
21 changes: 6 additions & 15 deletions opal/browser/dom/element/image.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
# backtick_javascript: true

module Browser; module DOM; class Element < Node

class Image < Element
def_selector "img"

def complete?
`#@native.complete`
end

def cross?
`#@native.crossOrigin`
end

def height
`#@native.naturalHeight`
end

def width
`#@native.naturalWidth`
end
alias_native :complete?, :complete
alias_native :cross?, :crossOrigin
alias_native :height, :naturalHeight
alias_native :width, :naturalWidth
end

Img = Image
Expand Down
26 changes: 7 additions & 19 deletions opal/browser/dom/element/input.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# backtick_javascript: true

module Browser; module DOM; class Element < Node

class Input < Element
Expand All @@ -14,21 +16,11 @@ def value
}
end

def value=(value)
`#@native.value = #{value}`
end

def name_
`#@native.name`
end

def type
`#@native.type`
end

def checked?
`#@native.checked`
end
alias_native :value=
alias_native :name_, :name
alias_native :type
alias_native :checked?, :checked
alias_native :enabled?, :enabled

def check!
`#@native.checked = 'checked'`
Expand All @@ -38,10 +30,6 @@ def uncheck!
`#@native.checked = ''`
end

def enabled?
`#@native.enabled`
end

def disable!
`#@native.disabled = 'disabled'`
end
Expand Down
7 changes: 4 additions & 3 deletions opal/browser/dom/element/media.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
module Browser; module DOM; class Element < Node

class Media < Element
def play
`#@native.play()`
end
alias_native :play
alias_native :pause
alias_native :time, :currentTime
alias_native :time=, :currentTime
end

class Video < Media
Expand Down
2 changes: 2 additions & 0 deletions opal/browser/dom/element/offset.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# backtick_javascript: true

module Browser; module DOM; class Element < Node

class Offset
Expand Down
2 changes: 2 additions & 0 deletions opal/browser/dom/element/scroll.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# backtick_javascript: true

module Browser; module DOM; class Element < Node

# @todo Consider using the new interfaces which allow for optional
Expand Down
11 changes: 4 additions & 7 deletions opal/browser/dom/element/select.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# backtick_javascript: true

module Browser; module DOM; class Element < Node

class Select < Element
Expand All @@ -14,9 +16,7 @@ def value
}
end

def value= value
`#@native.value = #{value.to_n}`
end
alias_native :value=

def labels
NodeSet[Native::Array.new(`#@native.labels`)]
Expand All @@ -30,10 +30,7 @@ def option
DOM(`#@native.options[#@native.selectedIndex]`)
end

def index
`#@native.selectedIndex`
end

alias_native :index, :selectedIndex
alias_native :multiple?, :multiple
alias_native :required?, :required
alias_native :length
Expand Down
18 changes: 6 additions & 12 deletions opal/browser/dom/element/size.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module Browser; module DOM; class Element < Node

class Size
include Native::Wrapper

attr_reader :element

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

# @!attribute width
# @return [Integer] the element width
def width
`#@native.offsetWidth`
end
alias_native :width, :offsetWidth

def width=(value)
@element.style[:width] = value
end

# @!attribute height
# @return [Integer] the element height
def height
`#@native.offsetHeight`
end
alias_native :height, :offsetHeight

def height=(value)
@element.style[:height] = value
end

# @!attribute client_width
# @return [Integer] the content-box width of an element
def client_width
`#@native.clientWidth`
end
alias_native :client_width, :clientWidth

# @!attribute client_height
# @return [Integer] the content-box height of an element
def client_height
`#@native.clientHeight`
end
alias_native :client_height, :clientHeight
end

end; end; end
2 changes: 2 additions & 0 deletions opal/browser/dom/element/template.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# backtick_javascript: true

module Browser; module DOM; class Element < Node

class Template < Element
Expand Down
6 changes: 3 additions & 3 deletions opal/browser/dom/element/textarea.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# backtick_javascript: true

module Browser; module DOM; class Element < Node

class Textarea < Element
Expand All @@ -14,9 +16,7 @@ def value
}
end

def value=(value)
`#@native.value = #{value}`
end
alias_native :value=

def clear
`#@native.value = ''`
Expand Down
12 changes: 5 additions & 7 deletions opal/browser/event/animation.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# backtick_javascript: true

module Browser; class Event

class Animation < Event
Expand All @@ -8,13 +10,9 @@ def self.supported?
end

class Definition < Definition
def animation=(value)
`#@native.animationName = #{value}`
end

def elapsed=(value)
`#@native.elapsedTime = #{value}`
end
alias_native :name=, :animationName=
alias_native :animation=, :animationName=
alias_native :elapsed=, :elapsedTime=
end

if Browser.supports? 'Event.constructor'
Expand Down
16 changes: 5 additions & 11 deletions opal/browser/event/audio_processing.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# backtick_javascript: true

module Browser; class Event

class AudioProcessing < Event
Expand All @@ -8,17 +10,9 @@ def self.supported?
end

class Definition < Definition
def time=(value)
`#@native.playbackTime = #{value}`
end

def input=(value)
`#@native.inputBuffer = #{value}`
end

def output=(value)
`#@native.outputBuffer = #{value}`
end
alias_native :time=, :playbackTime=
alias_native :input=, :inputBuffer=
alias_native :output=, :outputBuffer=
end

if Browser.supports? 'Event.constructor'
Expand Down
10 changes: 4 additions & 6 deletions opal/browser/event/base.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# backtick_javascript: true

module Browser

class Event
Expand All @@ -16,14 +18,10 @@ def self.new(&block)
end

# Set the event as bubbling.
def bubbles=(value)
`#@native.bubbles = #{value}`
end
alias_native :bubbles=

# Set the event as cancelable.
def cancelable=(value)
`#@native.cancelable = #{value}`
end
alias_native :cancelable=
end

module Target
Expand Down
2 changes: 2 additions & 0 deletions opal/browser/event/before_unload.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# backtick_javascript: true

module Browser; class Event

class BeforeUnload < Event
Expand Down
11 changes: 4 additions & 7 deletions opal/browser/event/clipboard.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# backtick_javascript: true

module Browser; class Event

class Clipboard < Event
Expand All @@ -8,13 +10,8 @@ def self.supported?
end

class Definition < Definition
def data=(value)
`#@native.data = #{value}`
end

def type=(value)
`#@native.dataType = #{value}`
end
alias_native :data=
alias_native :type=, :dataType=
end

if Browser.supports? 'Event.constructor'
Expand Down
11 changes: 4 additions & 7 deletions opal/browser/event/close.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# backtick_javascript: true

module Browser; class Event

class Close < Event
Expand All @@ -8,13 +10,8 @@ def self.supported?
end

class Definition < Definition
def code=(value)
`#@native.code = #{value}`
end

def reason=(value)
`#@native.reason = #{value}`
end
alias_native :code=
alias_native :reason=

def clean!(value)
`#@native.wasClean = true`
Expand Down
Loading

0 comments on commit 3c657a0

Please sign in to comment.