Skip to content

Commit

Permalink
Fixes parentModule bug
Browse files Browse the repository at this point in the history
  • Loading branch information
dawnerd committed Dec 2, 2016
1 parent 888e6d7 commit 801806e
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.0.0
6.7.0
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
3.1.0 / 2016-12-01
==================

* Fixes a bug from last version where `parentModule` wouldn't return correctly.

3.0.0 / 2016-11-24
==================

Expand Down
12 changes: 6 additions & 6 deletions dist/domodule.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ var Domodule = function () {
this.moduleName = this.el.dataset.module;

this.verifyOptions();
this.storeRef();
this.setupActions();
this.setupNamed();
this.storeRef();

return this;
}
Expand Down Expand Up @@ -68,7 +68,7 @@ var Domodule = function () {
for (var _iterator = this.find('[data-action]')[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var action = _step.value;

if ((0, _getParentModule2.default)(action).dataset.module === this.moduleName) {
if (~~(0, _getParentModule2.default)(action).dataset.moduleUid === this.id) {
this.setupAction(action);
}
}
Expand Down Expand Up @@ -117,7 +117,7 @@ var Domodule = function () {
for (var _iterator2 = this.find('[data-name]')[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var named = _step2.value;

if ((0, _getParentModule2.default)(named).dataset.module !== this.moduleName) {
if (~~(0, _getParentModule2.default)(named).dataset.moduleUid !== this.id) {
continue;
}

Expand Down Expand Up @@ -152,8 +152,8 @@ var Domodule = function () {
return false;
}

var id = Domodule.refs.length;
this.el.dataset.moduleUid = id;
this.id = Domodule.refs.length;
this.el.dataset.moduleUid = this.id;
Domodule.refs.push(this);
}
}, {
Expand Down Expand Up @@ -308,7 +308,7 @@ function findParent(elem) {
return elem.parentNode;
}

findParent(elem.parentNode);
return findParent(elem.parentNode);
}

return elem;
Expand Down
10 changes: 5 additions & 5 deletions lib/domodule.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ export default class Domodule { // eslint-disable-line no-unused-vars
this.moduleName = this.el.dataset.module;

this.verifyOptions();
this.storeRef();
this.setupActions();
this.setupNamed();
this.storeRef();

return this;
}
Expand All @@ -36,7 +36,7 @@ export default class Domodule { // eslint-disable-line no-unused-vars
this.setupAction(this.el);

for (const action of this.find('[data-action]')) {
if (parentModule(action).dataset.module === this.moduleName) {
if (~~parentModule(action).dataset.moduleUid === this.id) {
this.setupAction(action);
}
}
Expand Down Expand Up @@ -68,7 +68,7 @@ export default class Domodule { // eslint-disable-line no-unused-vars

setupNamed() {
for (const named of this.find('[data-name]')) {
if (parentModule(named).dataset.module !== this.moduleName) {
if (~~parentModule(named).dataset.moduleUid !== this.id) {
continue;
}

Expand All @@ -88,8 +88,8 @@ export default class Domodule { // eslint-disable-line no-unused-vars
return false;
}

const id = Domodule.refs.length;
this.el.dataset.moduleUid = id;
this.id = Domodule.refs.length;
this.el.dataset.moduleUid = this.id;
Domodule.refs.push(this);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/getParentModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function findParent(elem) {
return elem.parentNode;
}

findParent(elem.parentNode);
return findParent(elem.parentNode);
}

return elem;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "domodule",
"version": "3.0.0",
"version": "3.1.0",
"description": "Class based modules",
"main": "dist/domodule.js",
"keywords": [
Expand Down

0 comments on commit 801806e

Please sign in to comment.