MINOR BREAKING CHANGE IN BLAZE: Template.currentData and Template.parentData

552 views
Skip to first unread message

Oleksandr Stubailo

unread,
Jan 28, 2015, 2:39:11 PM1/28/15
to meteo...@googlegroups.com, meteor-core

We discovered an inconsistency/bug with Template.currentData and Template.parentData, especially when used together with custom block helpers, tracked by this issue: https://github.com/meteor/meteor/issues/3303

A related issue was that Template.currentData did something different inside event handlers from what it did inside helpers, and was inconsistent with this inside the handler function. In helpers, Template.currentData returned the current data context where the helper was used, but in event handlers, Template.currentData returned the data context of the template instead of the current element. After considering the situation, we have decided to introduce a breaking change into Blaze with the assumption that not many people were using the previous functionality.

Now, Template.currentData works like this:

  • Inside an onCreated, onRendered, or onDestroyed callback, returns the data context of the template.
  • Inside a helper, returns the data context of the DOM node where the helper was used.
  • Inside an event handler, returns the data context of the element that fired the event.

To try out this new change, run your app with meteor --release TEMPLATE-C...@0.0.1.

Let us know how this change affects your app or package!

Thanks,
Sashko

Reply all
Reply to author
Forward
0 new messages