Skip to content

Commit 85f7c42

Browse files
committed
Use Opal.bridge_class() to handle brigding Element to jQuery
1 parent 902940a commit 85f7c42

File tree

2 files changed

+14
-22
lines changed

2 files changed

+14
-22
lines changed

opal/opal-jquery/element.rb

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
1-
class Element
2-
%x{
3-
var root = $opal.global, dom_class;
4-
5-
if (root.jQuery) {
6-
dom_class = jQuery
7-
}
8-
else if (root.Zepto) {
9-
dom_class = Zepto.zepto.Z;
10-
}
11-
else {
12-
throw new Error("jQuery must be included before opal-jquery");
13-
}
1+
%x{
2+
var root = $opal.global, dom_class;
143
15-
self._proto = dom_class.prototype, def = self._proto;
16-
dom_class.prototype._klass = self;
4+
if (root.jQuery) {
5+
dom_class = jQuery
6+
}
7+
else if (root.Zepto) {
8+
dom_class = Zepto.zepto.Z;
9+
}
10+
else {
11+
throw new Error("jQuery must be included before opal-jquery");
1712
}
1813
19-
include Kernel
14+
Opal.bridge_class('Element', dom_class);
15+
}
16+
17+
class Element
2018
include Enumerable
2119

2220
def self.find(selector)

spec/spec_helper.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
require 'opal-rspec'
22
require 'opal-jquery'
33

4-
# FIXME: wtf? why isnt Element getting should and should_not
5-
class Element
6-
`def.$should = $opal.top.$should`
7-
`def.$should_not = $opal.top.$should_not`
8-
end
9-
104
module JqueryHelpers
115
# Add some html code to the body tag ready for testing. This will
126
# be added before each test, then removed after each test. It is

0 commit comments

Comments
 (0)