Skip to content

Commit

Permalink
update self check (truth and false) on every loop iteration
Browse files Browse the repository at this point in the history
also fix property value and property name detection
  • Loading branch information
ifedapoolarewaju committed Feb 8, 2019
1 parent 1e2da7a commit b69418d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
### 0.1.3 / 2019-02-07 ###

* update `self` check (truth and false) on every loop iteration
* fix property value and property name detection

### 0.1.2 / 2019-02-07 ###

* Add support for triggers
Expand Down
2 changes: 1 addition & 1 deletion dist/no.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ input[type=text] {

.sidemenu {
position: absolute;
// minus height of header;
/* minus height of header; */
height: calc(100% - 56px);
top: 56px;
left: -360px;
Expand Down
15 changes: 11 additions & 4 deletions no.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,19 @@
var target = el;
isSelf = true;
} else {
isSelf = false;
var target = paramValues[0];
}

var propertyName = propertyOrEventType;
var propertyValue;
if (action !== 'remove' || action !== 'reset') {
var index = this_._getPropertyValueIndex(propertyOrEventType, isSelf)
if (action !== 'reset') {
var index = this_._getPropertyValueIndex(propertyOrEventType, isSelf);
// join space containing values that might have been split.
propertyValue = paramValues.splice(index).join(' ')
propertyValue = paramValues.slice(index).join(' ');
if (propertyOrEventType === 'attribute') {
propertyName = paramValues[index - 1];
}
}

var options = {
Expand All @@ -83,7 +88,7 @@
sourceElement: el,
propertyOrEventType: propertyOrEventType,
propertyValue: propertyValue,
propertyName: propertyOrEventType === 'attribute' ? paramValues[1] : propertyOrEventType
propertyName: propertyName
}

el.addEventListener(eventType, function(e) {
Expand Down Expand Up @@ -141,6 +146,8 @@
}

NoJS.prototype._getPropertyValueIndex = function (propertyOrEventType, isSelf) {
// if props type is attribute, the signature takes the form
// on-[evtType]-[action]-attribute = "target propertyName propertyValue"
var index = propertyOrEventType === 'attribute' ? 2 : 1;
return isSelf ? index - 1 : index;
}
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": "nojs",
"version": "0.1.2",
"version": "0.1.3",
"description": "Library that helps minimize js you have to write",
"main": "no.js",
"scripts": {
Expand Down

0 comments on commit b69418d

Please sign in to comment.