Skip to content

Commit

Permalink
Use Opal.bridge_class() to handle brigding Element to jQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed Nov 2, 2013
1 parent 902940a commit 85f7c42
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 22 deletions.
30 changes: 14 additions & 16 deletions opal/opal-jquery/element.rb
@@ -1,22 +1,20 @@
class Element
%x{
var root = $opal.global, dom_class;
if (root.jQuery) {
dom_class = jQuery
}
else if (root.Zepto) {
dom_class = Zepto.zepto.Z;
}
else {
throw new Error("jQuery must be included before opal-jquery");
}
%x{
var root = $opal.global, dom_class;
self._proto = dom_class.prototype, def = self._proto;
dom_class.prototype._klass = self;
if (root.jQuery) {
dom_class = jQuery
}
else if (root.Zepto) {
dom_class = Zepto.zepto.Z;
}
else {
throw new Error("jQuery must be included before opal-jquery");
}
include Kernel
Opal.bridge_class('Element', dom_class);
}

class Element
include Enumerable

def self.find(selector)
Expand Down
6 changes: 0 additions & 6 deletions spec/spec_helper.rb
@@ -1,12 +1,6 @@
require 'opal-rspec'
require 'opal-jquery'

# FIXME: wtf? why isnt Element getting should and should_not
class Element
`def.$should = $opal.top.$should`
`def.$should_not = $opal.top.$should_not`
end

module JqueryHelpers
# Add some html code to the body tag ready for testing. This will
# be added before each test, then removed after each test. It is
Expand Down

0 comments on commit 85f7c42

Please sign in to comment.