tildeio / htmlbars

A variant of Handlebars that emits DOM and allows you to write helpers that manipulate live DOM nodes
MIT License
1.6k stars 193 forks source link

inline hook doesn't update morph to false-like values #348

Closed jmurphyau closed 9 years ago

jmurphyau commented 9 years ago

The below block of code in the inline hook causes issues when a false-like value is returned.

If morph.lastValue is hello and you want to update the value to a blank value (e.g. null or '') the check result && result.value stops the value from actually being updated.

if (result && result.value) {
  var value = result.value;
  if (morph.lastValue !== value) {
    morph.setContent(value);
  }
  morph.lastValue = value;
}

In the new Ember {{get}} keyword there is a particular workaround in place to compensate for this issue.

rwjblue commented 9 years ago

I believe it should be result && 'value' in result. Would you mind making a PR with a test?