Skip to content

Correct an Opal v1.4 compatibility issue #96

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

Merged
merged 3 commits into from
Dec 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 8 additions & 25 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,23 @@ jobs:
matrix:
combo:
- name: Chromium/Linux/Opal-master
browser: chrome
os: ubuntu-latest
opal: master
- name: Chromium/Linux/Opal-1.4
opal: 1.4
- name: Chromium/Linux/Opal-1.3/PromiseV2
browser: chrome
os: ubuntu-latest
opal: 1.3
promise: v2
- name: Chromium/Linux/Opal-1.3
browser: chrome
os: ubuntu-latest
opal: 1.3
- name: Chromium/Linux/Opal-1.2
browser: chrome
os: ubuntu-latest
opal: 1.2
- name: Chromium/Linux/Opal-1.0
browser: chrome
os: ubuntu-latest
opal: '1.0'
- name: Chromium/Linux/Ruby-2.7
browser: chrome
os: ubuntu-latest
ruby: 2.7
- name: Chromium/Linux/Ruby-2.6
browser: chrome
os: ubuntu-latest
ruby: 2.6
- name: Firefox/Linux
browser: gecko
os: ubuntu-latest
- name: Chromium/Windows
browser: chrome
os: windows-latest
- name: Firefox/Windows
browser: gecko
Expand All @@ -57,7 +41,6 @@ jobs:
browser: edge
os: windows-latest
- name: Chromium/macOS
browser: chrome
os: macos-latest
- name: Firefox/macOS
browser: gecko
Expand All @@ -66,7 +49,7 @@ jobs:
browser: safari
os: macos-latest

runs-on: ${{ matrix.combo.os }}
runs-on: ${{ matrix.combo.os || 'ubuntu-latest' }}

steps:
- uses: actions/checkout@v2
Expand All @@ -81,15 +64,15 @@ jobs:
- uses: actions/cache@v2
with:
path: ./vendor/bundle
key: ${{ runner.os }}-${{ matrix.combo.ruby || '3.0' }}-gems-${{ matrix.combo.opal || '1.2.0.beta1' }}-${{ github.ref }}-${{ hashFiles('**/Gemfile.lock') }}
key: ${{ runner.os }}-${{ matrix.combo.ruby || '3.0' }}-gems-${{ matrix.combo.opal || '1.3' }}-${{ github.ref }}-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.combo.ruby || '3.0' }}-gems-${{ matrix.combo.opal || '1.2.0.beta1' }}-${{ github.ref }}
${{ runner.os }}-${{ matrix.combo.ruby || '3.0' }}-gems-${{ matrix.combo.opal || '1.2.0.beta1' }}-master
${{ runner.os }}-${{ matrix.combo.ruby || '3.0' }}-gems-${{ matrix.combo.opal || '1.2.0.beta1' }}-
${{ runner.os }}-${{ matrix.combo.ruby || '3.0' }}-gems-${{ matrix.combo.opal || '1.3' }}-${{ github.ref }}
${{ runner.os }}-${{ matrix.combo.ruby || '3.0' }}-gems-${{ matrix.combo.opal || '1.3' }}-master
${{ runner.os }}-${{ matrix.combo.ruby || '3.0' }}-gems-${{ matrix.combo.opal || '1.3' }}-
${{ runner.os }}-${{ matrix.combo.ruby || '3.0' }}-gems-
- name: bundle install
run: |
bundle config path $PWD/vendor/bundle
bundle install --jobs 4 --retry 3
bundle clean
- run: bundle exec rake selenium_${{ matrix.combo.browser }}
- run: bundle exec rake selenium_${{ matrix.combo.browser || 'chrome' }}
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 0.3.3
* Compatibility fix for Opal 1.4

## 0.3.2
* Cookie: refactor the module
* Note in documentation it's available as `$document.cookies` and it's the preferred way to access it
Expand Down
54 changes: 33 additions & 21 deletions opal/browser/support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,16 @@ def self.supports?(feature)
when 'Window.send (Asynchronous)'
if defined?(`window.postMessage`) && !defined?(`window.importScripts`)
%x{
var ok = true,
old = window.onmessage;
(function() {
var ok = true,
old = window.onmessage;

window.onmessage = function() { ok = false; };
window.postMessage("", "*")
window.onmessage = old;
window.onmessage = function() { ok = false; };
window.postMessage("", "*")
window.onmessage = old;

return ok;
return ok;
})()
}
end

Expand All @@ -106,45 +108,55 @@ def self.supports?(feature)

when 'Attr.isId'
%x{
var div = document.createElement('div');
div.setAttribute('id', 'xxxxxxxxxxxxx');
(function() {
var div = document.createElement('div');
div.setAttribute('id', 'xxxxxxxxxxxxx');

return typeof(div.attributes['id'].isId) !== "undefined";
return typeof(div.attributes['id'].isId) !== "undefined";
})()
}

when 'Element.addBehavior'
defined?(`document.documentElement.addBehavior`)

when 'Element.className'
%x{
var div = document.createElement("div");
div.setAttribute('className', 'x');
(function() {
var div = document.createElement("div");
div.setAttribute('className', 'x');

return div.className === 'x';
return div.className === 'x';
})()
}

when 'Element.class'
%x{
var div = document.createElement("div");
div.setAttribute('class', 'x');
(function() {
var div = document.createElement("div");
div.setAttribute('class', 'x');

return div.className === 'x';
return div.className === 'x';
})()
}

when 'Element.for'
%x{
var label = document.createElement("label");
label.setAttribute('for', 'x');
(function() {
var label = document.createElement("label");
label.setAttribute('for', 'x');

return label.htmlFor === 'x';
return label.htmlFor === 'x';
})()
}

when 'Element.htmlFor'
%x{
var label = document.createElement("label");
label.setAttribute('htmlFor', 'x');
(function() {
var label = document.createElement("label");
label.setAttribute('htmlFor', 'x');

return label.htmlFor === 'x';
return label.htmlFor === 'x';
})()
}

when 'Element.clientSize'
Expand Down
2 changes: 1 addition & 1 deletion opal/browser/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Browser
VERSION = '0.3.2'
VERSION = '0.3.3'
end