Skip to content

Commit b69418d

Browse files
update self check (truth and false) on every loop iteration
also fix property value and property name detection
1 parent 1e2da7a commit b69418d

File tree

5 files changed

+19
-7
lines changed

5 files changed

+19
-7
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
### 0.1.3 / 2019-02-07 ###
2+
3+
* update `self` check (truth and false) on every loop iteration
4+
* fix property value and property name detection
5+
16
### 0.1.2 / 2019-02-07 ###
27

38
* Add support for triggers

dist/no.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ input[type=text] {
5151

5252
.sidemenu {
5353
position: absolute;
54-
// minus height of header;
54+
/* minus height of header; */
5555
height: calc(100% - 56px);
5656
top: 56px;
5757
left: -360px;

no.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,19 @@
6767
var target = el;
6868
isSelf = true;
6969
} else {
70+
isSelf = false;
7071
var target = paramValues[0];
7172
}
7273

74+
var propertyName = propertyOrEventType;
7375
var propertyValue;
74-
if (action !== 'remove' || action !== 'reset') {
75-
var index = this_._getPropertyValueIndex(propertyOrEventType, isSelf)
76+
if (action !== 'reset') {
77+
var index = this_._getPropertyValueIndex(propertyOrEventType, isSelf);
7678
// join space containing values that might have been split.
77-
propertyValue = paramValues.splice(index).join(' ')
79+
propertyValue = paramValues.slice(index).join(' ');
80+
if (propertyOrEventType === 'attribute') {
81+
propertyName = paramValues[index - 1];
82+
}
7883
}
7984

8085
var options = {
@@ -83,7 +88,7 @@
8388
sourceElement: el,
8489
propertyOrEventType: propertyOrEventType,
8590
propertyValue: propertyValue,
86-
propertyName: propertyOrEventType === 'attribute' ? paramValues[1] : propertyOrEventType
91+
propertyName: propertyName
8792
}
8893

8994
el.addEventListener(eventType, function(e) {
@@ -141,6 +146,8 @@
141146
}
142147

143148
NoJS.prototype._getPropertyValueIndex = function (propertyOrEventType, isSelf) {
149+
// if props type is attribute, the signature takes the form
150+
// on-[evtType]-[action]-attribute = "target propertyName propertyValue"
144151
var index = propertyOrEventType === 'attribute' ? 2 : 1;
145152
return isSelf ? index - 1 : index;
146153
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nojs",
3-
"version": "0.1.2",
3+
"version": "0.1.3",
44
"description": "Library that helps minimize js you have to write",
55
"main": "no.js",
66
"scripts": {

0 commit comments

Comments
 (0)