vendor/assets/javascripts/emerson/sink.js in emerson-0.0.11 vs vendor/assets/javascripts/emerson/sink.js in emerson-0.1.0.pre.1
- old
+ new
@@ -1,10 +1,7 @@
// Emerson Sink
//
-// "sink - a body or process that acts to absorb or remove energy or a
-// particular component from a system."
-//
// Adds...
(function(ns) {
// Emerson Extension
@@ -108,62 +105,31 @@
return result;
}
// ### process
// ...
- // TODO: DRY-up the update code.
function process(element, matches) {
var parts, strategy, clone;
if(matches.length > 1) {
- matches.each(function(current) {
- current = $(this);
+ matches.each(function() {
clone = prepare(element.clone(true));
- parts = current.data('sink').split(':');
+ parts = $(this).data('sink').split(':');
strategy = parts[1] || 'replace';
- current.trigger('sink:before');
- strategies[strategy]
- .call(clone, current)
- .each(forceCalculateStyle)
+ $(this).trigger('sink:before');
+ strategies[strategy].call(clone, $(this))
.trigger('sink:after');
clone.trigger('sink:after');
});
}
else {
parts = matches.data('sink').split(':');
strategy = parts[1] || 'replace';
matches.trigger('sink:before');
- strategies[strategy]
- .call(prepare(element), matches)
- .each(forceCalculateStyle)
+ strategies[strategy].call(prepare(element), matches)
.trigger('sink:after');
}
- }
-
- // ### forceCalculateStyle
- //
- // forceCalculateStyle.call(node)
- //
- // Given a DOM node, force style calculation. e.g., this might be useful for
- // establishing a render baseline to enable CSS animations. Note that the
- // particular property accessed is arbitrary.
- //
- // TODO: Add spec coverage (needs pre-/post-render and some CSS transition).
- //
- // Credits:
- //
- // * Doug Rohrer & Rachel Heaton for the bug fix:
- // <https://github.com/coreyti/emerson/pull/9>
- function forceCalculateStyle() {
- if(this.jquery) {
- window.getComputedStyle(this[0]).opacity;
- }
- else {
- window.getComputedStyle(this).opacity;
- }
-
- return this;
}
})(Emerson);