Commit Graph

7076 Commits

Author SHA1 Message Date
David Greenspan
5a1edba2ef Only look for helpers in the current template
Revert the new feature that all helpers in enclosing templates are visible, including helpers on the template that called the current template (for example) and helpers on UI.body.

Making helpers visible to sub-templates was a major change that was never properly justified or thought through.  Helpers take precedence over data properties, and having helpers "leak" down through the app could have bad consequences, even if it's useful for defining helpers on a group of related templates.  There was a point in shark's history where we needed this dynamic lookup in order for helpers to work in block tags, but that's no longer the case.

Now, helpers are only visible to the lexical body of the template they are defined on (except for global helpers defined with UI.registerHelper).

Ran tests in Chrome; ran todos and docs.
release/0.8.0-rc2 release/test-0.8.0-rc2
2014-03-24 17:45:05 -07:00
Avital Oliver
883188dc70 Revert "Mark backcompat on some Handlebars functions"
This reverts commit b777b04a66.
2014-03-24 14:37:28 -07:00
Avital Oliver
b777b04a66 Mark backcompat on some Handlebars functions 2014-03-24 14:24:03 -07:00
David Greenspan
30cd85f951 Fix templateInstance findAll, add $ alias
findAll was always supposed to return a jQuery object if you use jQuery (which is always at the moment).

Now `this.$` is an alias for `this.findAll`, as well.
release/0.8.0-rc1
2014-03-24 13:20:40 -07:00
David Greenspan
480016ea8b Fix #with 2014-03-23 09:53:53 -07:00
David Greenspan
a1d1549d77 Failing tests for #with behavior 2014-03-23 09:10:04 -07:00
David Greenspan
1fcb33e61b parse.js: Add more comments 2014-03-22 09:57:46 -07:00
Avital Oliver
4ba1abb79e Handlebars.registerHelper -> UI.registerHelper release/0.8.0-rc0-build1 release/0.8.0-rc0 2014-03-22 00:47:02 -07:00
Avital Oliver
cc4865c114 Handlebars._escape -> UI._escape 2014-03-22 00:35:51 -07:00
Avital Oliver
c2d985c235 Handlebars.SafeString -> Spacebars.SafeString 2014-03-22 00:35:26 -07:00
Avital Oliver
dd6a2a2e5e Pass empty object as 'this' when no data context
in template helpers and event handlers. 'this' must be an object and
it can't be null, so an empty object is the best we can do (and surely
better than 'window' which is what we had before this commit)

This was a regression from Spark.
2014-03-21 23:05:45 -07:00
Avital Oliver
9ef97fc297 Better parsing for {{! }} comments
We now no longer check whether we're at a closing
HTML tag by peeking for "</" since that would fail
if there were a {{! }} comment directly before it.

Instead, we tokenize and then rewind. Presumably
this does have an effect on compilation time but it's
probably fine. An alternative would have been to
explicitly parse {{! }} comments rather than implicitly
skipping them before generally parsing tokens.
2014-03-21 22:08:02 -07:00
David Greenspan
09b9b4adba Tower of hacks to get shark deps right
The implementation is getting really, really ugly.  Just want to get to correctness.

We now stop autoruns not just when started from `materialize` but also `toHTML`, `toText`, and `evaluate`, which is important for HTML attributes.  Reactive regions inside attributes aren't individually autorun; the design is that their dependencies will cause the entire attribute updater to be invalidated and re-run.  In other words, HTML.toText doesn't have internal re-runs but it does register dependencies on the current computation.  In fact, however, the presence of emboxedValues means that there *are* autoruns that need to be stopped, even in toText and evaluate.

The hack where we define a `.materialized()` callback for the benefit of UI.With falls short, because toText et al. don't call it.  The current workaround is yet worse hacks in htmljs (stopWithLater).

Finally, the fact that UI.If, UI.Unless, and Spacebars.include return reactive closures that close over emboxedValues is a problem when those same closures are reused in recalculating attributes.  The intent was that recalculating attributes should tear down any boxes internal to the attribute calculation and start fresh, but when we reuse closures that close over boxes, we are reusing boxes, and if those boxes have been stopped we lose correctness.  The ugly hack to get this to work for now is to have the boxes in If, Unless and include not be per reactive closure but per currentComputation, i.e. per autorun.  Since toText et al. don't normally autorun reactive closures, we add an autorun so that they get their own Computation objects.  This hack is supported by UI.namedEmboxValue and callReactiveFunction.

The good news is that the right answer is buried in here somewhere.
2014-03-21 03:54:28 -07:00
David Greenspan
7e49210eec Deps: Do less function wrapping
Now you can actually see function source code when you inspect _onInvalidateCallbacks in the debugger.  Instead of wrapping a bunch of stuff around the callbacks before enqueuing them, we move the logic to where they are called.
2014-03-21 02:53:34 -07:00
David Greenspan
54e43e7151 Deps: Take noYieldsAllowed off client call stack 2014-03-21 02:18:05 -07:00
David Greenspan
f12845fc33 Add failing tests for reactive attribute stoppage 2014-03-21 00:13:24 -07:00
David Greenspan
726e90930e Stop more helpers
Stop emboxed values again from reactive ranges on DOM removal
2014-03-21 00:12:54 -07:00
David Greenspan
3d42ae9a5a Deps: Wrap functions more debuggably 2014-03-20 23:59:11 -07:00
David Greenspan
295268fb8c Fix #unless to stop helpers 2014-03-20 18:02:41 -07:00
Avital Oliver
3eb4e97112 Greenspan comments on keyword argument parsing 2014-03-20 14:14:54 -07:00
Avital Oliver
adbadbfbc6 Allow hyphens in kwargs to inclusions and block helpers
(and other characters)
2014-03-20 13:39:54 -07:00
David Greenspan
2b10bf3794 Remove emboxValue tests
emboxValue is going away anyway
2014-03-20 10:25:39 -07:00
David Greenspan
c910fce4c6 Make emboxValue dumb; explicitly stop autoruns 2014-03-20 09:39:13 -07:00
David Greenspan
6e945e29e7 Test no helper re-run with inclusions, callbacks 2014-03-20 09:38:35 -07:00
Avital Oliver
fba5d95cfe Update todos to the new pattern for 'checked' attributes 2014-03-19 13:36:45 -07:00
Avital Oliver
2f7724ac2a New failing test for re-running helpers in #each within #with 2014-03-18 21:53:07 -07:00
David Greenspan
53c83be0b8 Make #each stop sooner; observe inside Deps comp
By doing the #each observe inside the current Deps computation from materialization, it will stop when the parent computation is invalidated.
2014-03-18 14:59:42 -07:00
David Greenspan
20db762c6d Modify test 2014-03-18 14:38:40 -07:00
David Greenspan
af9bc84ecc Test for helper re-run after template removed
(some failures)
2014-03-18 14:32:07 -07:00
David Greenspan
42258895be Hack to stop emboxed .data() sooner
This fixes cmather's test case for real this time (https://github.com/cmather/meteor-emboxed-issue)
2014-03-17 20:37:10 -07:00
David Greenspan
75b34dff39 rewrite emboxValue (doesn't fix everything yet) 2014-03-17 20:22:22 -07:00
Nick Martin
d8575d0a24 Merge branch 'devel' into shark release/0.7.2-rc1-with-blaze 2014-03-17 15:51:18 -07:00
David Glasser
8a16f50138 Ensure that hook.each is called from a Fiber
That gives us enough guarantees that we can simplify the error-handling
code.

We also ensure that the "new connection" handler in livedata_server runs
in a Fiber, which fixes a bug introduced in d049bf7506 where connections
from pre-pre1 clients would crash (due to Meteor.setTimeout which only
works in a Fiber).
2014-03-17 15:49:27 -07:00
Avital Oliver
6282e42b1d Test that helpers are called only once when invalidated.
(This was fixed by the recent commit eliminating Deps.isolateValue)
2014-03-17 15:24:14 -07:00
Avital Oliver
b97d9e143a Eliminate Deps.isolateValue
Unfortunately, using it always led to reactive functions
firing twice. Instead, we now use emboxValue in the two
cases we originally had Deps.isolateValue.
2014-03-17 15:09:52 -07:00
David Glasser
da96352c65 Make some white-box tests less flaky
If we want the *internal* state of the oplog driver to be consistent, we
need to make sure that we start our observes at a consistent point in
the oplog.  (ie, initial inserts need to have been fully processed, so
that we don't process them during the original QUERYING phase, which can
give us a different unpublished buffer.)

Note that only the white-box tests (looked at _unpublishedBuffer, eg)
appeared to be flaky: the actual docs published seemed to be correct in
all cases.
2014-03-17 12:11:21 -07:00
David Glasser
5486fd0b33 Merge branch 'sort-selector' into devel 2014-03-17 02:56:12 -07:00
David Glasser
93e1969560 history update 2014-03-17 02:56:07 -07:00
David Glasser
17297d98d7 make LocalCollection.Cursor easier to read
and whitespace cleanup
2014-03-17 02:17:06 -07:00
David Glasser
15fa6b2ab7 Pass Matcher to Sorter constructor 2014-03-17 02:17:06 -07:00
David Glasser
cda5152491 Refactor a test to remove magic numbers 2014-03-17 02:17:06 -07:00
David Glasser
d4241aa998 Improve ELEMENT_OPERATORS comment.
Make there be one consistent syntax for element operators.
2014-03-17 02:17:06 -07:00
David Glasser
8488047c13 support non-initial keys in sort selector filter 2014-03-17 02:17:06 -07:00
David Glasser
29cfa27ef3 support regexps in sort key filter
also in EJSON.clone
2014-03-17 02:17:06 -07:00
David Glasser
125051f2f8 more tests for sort/select, and fix a silly bug 2014-03-17 02:17:06 -07:00
David Glasser
17ec29603c Initial stab at fixing the sort/selector issue 2014-03-17 02:17:06 -07:00
David Glasser
8822386d7b test for affectedByModifier for $elemMatch 2014-03-17 02:17:06 -07:00
David Glasser
9968f19f8a Failing test for sort/selector issue 2014-03-17 02:17:05 -07:00
Nick Martin
4b2696eda4 Make test-only package internal. 2014-03-17 00:05:26 -07:00
Nick Martin
82fd3201a1 Fix CSS error in Firefox. default is not a good thing to put here. sans-serif makes it look better. 2014-03-16 22:46:02 -07:00