* Register v-on events on a child component * * @param {Vue} vm * @param {Element} el
(vm, el)
| 8093 | */ |
| 8094 | |
| 8095 | function registerComponentEvents(vm, el) { |
| 8096 | var attrs = el.attributes; |
| 8097 | var name, value, handler; |
| 8098 | for (var i = 0, l = attrs.length; i < l; i++) { |
| 8099 | name = attrs[i].name; |
| 8100 | if (eventRE.test(name)) { |
| 8101 | name = name.replace(eventRE, ''); |
| 8102 | // force the expression into a statement so that |
| 8103 | // it always dynamically resolves the method to call (#2670) |
| 8104 | // kinda ugly hack, but does the job. |
| 8105 | value = attrs[i].value; |
| 8106 | if (isSimplePath(value)) { |
| 8107 | value += '.apply(this, $arguments)'; |
| 8108 | } |
| 8109 | handler = (vm._scope || vm._context).$eval(value, true); |
| 8110 | handler._fromParent = true; |
| 8111 | vm.$on(name.replace(eventRE), handler); |
| 8112 | } |
| 8113 | } |
| 8114 | } |
| 8115 | |
| 8116 | /** |
| 8117 | * Register callbacks for option events and watchers. |
no test coverage detected