Skip to content

Commit

Permalink
Fixes #909 - Fix condition prevent bubbling DOM events from properly …
Browse files Browse the repository at this point in the history
…being attached to a component. (#910)
  • Loading branch information
austinkelleher committed Oct 27, 2017
1 parent 61cb964 commit 9f3dd90
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function attachBubblingEvent(componentDef, handlerMethodName, extraArgs) {
// where the extra args will be found when the UI component is
// rerendered in the browser

if (componentDef.___flags & FLAG_WILL_RERENDER_IN_BROWSER) {
if (!(componentDef.___flags & FLAG_WILL_RERENDER_IN_BROWSER)) {
if (eventIndex === 0) {
component.___bubblingDomEvents = [extraArgs];
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
onMount: function() {
window.splitComponent = this;
this.clicked = false;
},
handleClick: function (value) {
this.clicked = value;
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<button on-click('handleClick', true)/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"tags-dir": "./components"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
lasso-page dependencies=data.browserDependencies lasso=data.lasso

<!DOCTYPE html>
html lang="en"
head
meta charset="UTF-8"
title -- Marko Components Tests
lasso-head
body

div id="test"
div id="mocha"
div id="testsTarget"

split-component

lasso-body

init-components immediate

lasso-slot name="mocha-run"

browser-refresh
27 changes: 27 additions & 0 deletions test/autotests/components-pages/split-emit-multi-args/tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
var path = require('path');
var expect = require('chai').expect;

function triggerMouseEvent(el, type) {
var ev = document.createEvent("MouseEvent");
ev.initMouseEvent(
type,
true /* bubble */, true /* cancelable */,
window, null,
0, 0, 0, 0, /* coordinates */
false, false, false, false, /* modifier keys */
0 /*left*/, null
);
el.dispatchEvent(ev);
}

function triggerClick(el) {
triggerMouseEvent(el, 'click');
}

describe(path.basename(__dirname), function() {
it('should allow getEl() with a split component', function() {
var app = window.splitComponent;
triggerClick(app.el);
expect(app.clicked).to.equal(true);
});
});

0 comments on commit 9f3dd90

Please sign in to comment.