mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
Fixes #668 - Events handler in the include tag
This commit is contained in:
parent
de0c491fc6
commit
0a0430ab7d
@ -52,8 +52,6 @@ module.exports = function handleComponentBind() {
|
||||
let context = this.context;
|
||||
let builder = this.builder;
|
||||
|
||||
let internalBindAttr = el.getAttribute('_componentbind');
|
||||
|
||||
let componentModule;
|
||||
let rendererModulePath;
|
||||
let rendererModule = this.getRendererModule();
|
||||
@ -119,9 +117,7 @@ module.exports = function handleComponentBind() {
|
||||
true /* computed */)
|
||||
]));
|
||||
}
|
||||
} else if (internalBindAttr != null) {
|
||||
el.removeAttribute('_componentbind');
|
||||
|
||||
} else if (el.isFlagSet('hasComponentBind')) {
|
||||
componentModule = this.getComponentModule();
|
||||
rendererModulePath = this.getRendererModule();
|
||||
|
||||
|
||||
@ -255,7 +255,7 @@ module.exports = function handleRootNodes() {
|
||||
var nextKey = 0;
|
||||
|
||||
rootNodes.forEach((curNode, i) => {
|
||||
curNode.setAttributeValue('_componentbind');
|
||||
curNode.setFlag('hasComponentBind');
|
||||
|
||||
if (!curNode.hasAttribute('key') && !curNode.hasAttribute('ref')) {
|
||||
if (curNode.type === 'CustomTag' || rootNodes.length > 1) {
|
||||
|
||||
@ -45,6 +45,7 @@ module.exports = function transform(el, context) {
|
||||
if (el.tagName === 'widget-types') {
|
||||
context.setFlag('hasWidgetTypes');
|
||||
} else if (el.tagName === 'include') {
|
||||
transformHelper.handleComponentEvents();
|
||||
transformHelper.handleIncludeNode(el);
|
||||
transformHelper.getComponentArgs().compile(transformHelper);
|
||||
return;
|
||||
@ -55,8 +56,7 @@ module.exports = function transform(el, context) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (el.hasAttribute('_componentbind') || el.hasAttribute('w-bind')) {
|
||||
el.setFlag('hasComponentBind');
|
||||
if (el.isFlagSet('hasComponentBind') || el.hasAttribute('w-bind')) {
|
||||
transformHelper.handleComponentBind();
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,6 @@
|
||||
class {
|
||||
}
|
||||
|
||||
<button type="button" on-click('emit', 'hello')>
|
||||
Say hello
|
||||
</button>
|
||||
@ -0,0 +1,15 @@
|
||||
import helloComponent from './components/hello.marko';
|
||||
|
||||
class {
|
||||
onCreate() {
|
||||
this.helloReceived = false;
|
||||
}
|
||||
|
||||
handleHello() {
|
||||
this.helloReceived = true;
|
||||
}
|
||||
}
|
||||
|
||||
<div>
|
||||
<include(helloComponent) on-hello('handleHello')/>
|
||||
</div>
|
||||
@ -0,0 +1,11 @@
|
||||
var expect = require('chai').expect;
|
||||
|
||||
module.exports = function(helpers) {
|
||||
var component = helpers.mount(require('./index'), { });
|
||||
|
||||
expect(component.helloReceived).to.equal(false);
|
||||
|
||||
component.el.querySelector('button').click();
|
||||
|
||||
expect(component.helloReceived).to.equal(true);
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user