Skip to content

Commit

Permalink
Remove escaping from bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
TimvdLippe committed Feb 25, 2018
1 parent 8a5525b commit 8cd4947
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 24 deletions.
31 changes: 13 additions & 18 deletions lib/utils/binding-parser.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,13 @@
/* eslint-disable no-fallthrough */

const STATE = {
INITIAL: bindingData => {
let escaped = false;
return char => {
if (char === '\\') {
escaped = true;
} else if ((char === '{' || char === '[') && !escaped) {
return STATE.FIRSTOPENINGBINDING({
mode: char,
dependencies: [],
startChar: bindingData.startChar
});
} else {
escaped = false;
}
INITIAL: bindingData => char => {
if ((char === '{' || char === '[')) {
return STATE.FIRSTOPENINGBINDING({
mode: char,
dependencies: [],
startChar: bindingData.startChar
});
}
},
FIRSTOPENINGBINDING: bindingData => (char, i) => {
Expand All @@ -120,11 +113,13 @@
return STATE.INITIAL({});
},
FIRSTCHARACTERBINDING: (bindingData) => char => {
if (char === '!') {
bindingData.negate = true;
bindingData.startChar = i + 1;
if (char !== ' ' && char !== '\t' && char !== '\n') {
if (char === '!') {
bindingData.negate = true;
bindingData.startChar = i + 1;
}
return STATE.BINDING(bindingData)
}
return STATE.BINDING(bindingData)
},
BINDING: bindingData => (char, i) => {
switch (char) {
Expand Down
2 changes: 0 additions & 2 deletions test/unit/property-effects-elements.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
<span id="nonEnglishUnicode">{{objectWithNonEnglishUnicode.商品名}}</span>
<span id="booleanTrue">foo(field, true): {{computeWithBoolean(otherValue, true)}}</span>
<span id="booleanFalse">foo(field, false): {{computeWithBoolean(otherValue, false)}}</span>
<span id="escapeBinding">\{{escapeBinding}}\[[escapeBinding2]]</span>
</template>
<script>
let ComputingBehavior = {
Expand Down Expand Up @@ -322,7 +321,6 @@
return a + (bInfo && bInfo.base ? bInfo.base.value : 0);
},
computeWithBoolean: function(value, bool) {
console.log(bool)
return bool ? value : value * 2;
},
fireCustomNotifyingEvent: function() {
Expand Down
4 changes: 0 additions & 4 deletions test/unit/property-effects.html
Original file line number Diff line number Diff line change
Expand Up @@ -382,10 +382,6 @@
assert.equal(el.$.booleanFalse.textContent, 'foo(field, false): 20');
});

test('escape bindings', function() {
assert.equal(el.$.escapeBinding.textContent, '\{{escapeBinding}}\[[escapeBinding2]]');
});

test('class attribute without template scope not erased', function() {
var el = document.querySelector('.class1');
assert.notEqual(el, null, 'class without template scope is undefined');
Expand Down

0 comments on commit 8cd4947

Please sign in to comment.