Skip to content

Commit

Permalink
adding reversed slim-if check
Browse files Browse the repository at this point in the history
  • Loading branch information
eavichay committed Apr 27, 2017
1 parent 2a652d1 commit 263ff44
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
12 changes: 11 additions & 1 deletion Slim.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,9 @@ var Slim = function (_HTMLElement) {
} else if (descriptor.type === 'F') {
executor = function executor() {
var value = !!Slim.__lookup(descriptor.source, prop).obj;
if (descriptor.reversed) {
value = !value;
}
if (!value) {
if (descriptor.target.parentNode) {
descriptor.target.insertAdjacentElement('beforeBegin', descriptor.helper);
Expand Down Expand Up @@ -974,12 +977,19 @@ var Slim = function (_HTMLElement) {
}

if (attribute.nodeName === 'slim-if') {
var propertyName = attribute.nodeValue;
var reverse = false;
if (attribute.nodeValue.charAt(0) === '!') {
propertyName = propertyName.slice(1);
reverse = true;
}
return {
type: 'F',
target: child,
source: child._boundParent,
helper: document.createElement('slim-if-helper'),
properties: [attribute.nodeValue]
reversed: reverse,
properties: [propertyName]
};
}

Expand Down
Loading

0 comments on commit 263ff44

Please sign in to comment.