Commit Graph

3580 Commits

Author SHA1 Message Date
Avital Oliver
f728523599 Merge branch 'devel' into shark 2014-01-28 15:00:19 -08:00
Slava Kim
cb2f2adb1b Do less deep copies 2014-01-28 10:11:27 -08:00
David Glasser
a65b978972 Refactor OplogObserveDriver to use LocalCollection
This should be a good starting point for implementing limit/sort/skip.
2014-01-27 21:57:00 -08:00
David Glasser
980b70596d More comments about our sort inconsistency 2014-01-27 21:56:17 -08:00
David Glasser
782ff1bcae Optionify the barely-used LocalCollection name arg 2014-01-27 21:40:24 -08:00
David Glasser
ed83f00fc1 Rename _SynchronousQueue to _UnyieldingQueue
Allow server uses of LocalCollection to prefer _UnyieldingQueue. This
will mean that, as long as their observeChanges callbacks do not yield,
calls to insert/update/remove will not yield either.
2014-01-27 21:19:32 -08:00
David Glasser
390dafea01 Move _SynchronousQueue into another file
This commit does not build but exists so that the next commit shows
diffs better.
2014-01-27 21:18:24 -08:00
David Glasser
f065ffd80f Merge branch 'devel' into shark
Conflicts:
	packages/minimongo/minimongo.js
	packages/minimongo/observe.js
	packages/minimongo/wrap_transform.js
	packages/mongo-livedata/collection.js
	packages/mongo-livedata/mongo_driver.js
	packages/mongo-livedata/mongo_livedata_tests.js
2014-01-27 16:34:15 -08:00
David Glasser
d577b05136 Review of wrapTransform with avital
- move _makeNonreactive into wrapTransform
- Use EJSON.equals for _id comparison
- Return null for nonexistent transforms
- Use isPlainObject for objectness check
- Add unit tests; remove some end-to-end tests

Also, add an EJSON.clone to the recently backported observeHandle._fetch
2014-01-27 16:22:30 -08:00
David Glasser
b5a14c5d30 Initial backport of wrapTransform from shark 2014-01-27 15:25:19 -08:00
David Glasser
20766ac05e Backport observeHandle._fetch from shark 2014-01-27 15:25:19 -08:00
David Glasser
c5e90053f2 Fix bug caused by d868325 2014-01-27 15:22:55 -08:00
David Greenspan
b26f0271a0 Rename HTML.evaluate{Dynamic,}Attributes 2014-01-27 14:44:19 -08:00
David Greenspan
599ac16632 Treat null/undefined/false attributes as absent
So, in HTML, the following are equivalent, and both mean that a checkbox is checked, because the `checked` attribute is present:

- `<input type="checkbox" checked>`
- `<input type="checkbox" checked="">`

We can't mess with that.  On the other hand, in Spacebars before this commit, the following would *also* result in the checkbox being checked, regardless of whether `foo` evaluates to null, undefined, false, or the empty string:

- `<input type="checkbox" checked={{foo}}>`
- `<input type="checkbox" checked="{{foo}}">`

With this commit, the checkbox will NOT be checked if `foo` evaluates to null, undefined, or false.

To achieve this:

- In HTMLjs, an attribute is considered absent if its value is "nully" after being fully evaluated (i.e. after expanding functions and components via HTML.evaluateDynamicAttributes / HTML.evaluate).  A nully value is one consisting of null, undefined, an empty array, or an array of those things.  `false` is not nully and renders as "false".  An empty string is not nully, and will "prop open" an attribute that would otherwise collapse into absence.

- Spacebars.mustache converts null, undefined, and false to null.  So if you use {{foo}} anywhere in a template and foo evaluates to "false", that gets to converted to a null in HTMLjs (which is ignored).  (true is rendered as "true".)

- When parsing HTML, an attribute that consists of *no tokens* becomes an empty string in the HTMLjs, which props open the attribute (unlike null or an empty array).  (Since comment tokens are stripped during tokenization, if there are only comments in an attribute value that counts as no tokens.)
2014-01-27 14:44:19 -08:00
David Greenspan
7c58b08f53 Fix an apparent typo 2014-01-27 14:44:19 -08:00
David Greenspan
54a2423acb Don't ignore falsy helpers
We were weirdly ignoring helpers that were falsy constants, so in `Template.main.foo = 0` / `{{foo}}` you'd get nothing, while if you did `Template.main.foo = function () { return 0; }` you would get "0".
2014-01-27 14:44:19 -08:00
David Greenspan
43cb4f8cc8 Rename tests in html-tools package to html-tools 2014-01-27 14:44:19 -08:00
David Greenspan
30374854f0 jquery -> v1.10.2 2014-01-27 14:08:22 -08:00
David Greenspan
6300a72381 add missing semicolon
just happened to notice it
2014-01-27 14:02:01 -08:00
David Glasser
6471dce8fa Merge branch 'devel' into shark 2014-01-27 13:58:11 -08:00
Avital Oliver
d46a5e11b1 Correctly check for reserved template names 2014-01-26 11:52:27 -08:00
Avital Oliver
70aa948634 Isolate attributes on <p {{attrs}}>
A helper can return an object with a set of element attributes via
`<p {{attrs}}>`. When it re-runs due to a dependency changing the
value for a given attribute might stay the same. Test that the
attribute is not set on the DOM element.
2014-01-26 11:52:26 -08:00
Avital Oliver
72a5d4282c Correct helper return value isolation
- When helpers return SafeStrings, compare their underlying
  strings.
- When helpers return objects (such as for dynamic attributes),
  never isolate. The objects may have been mutated directly.
  AttributeHandler ends up only affecting real changes.
2014-01-26 11:52:26 -08:00
Avital Oliver
1223783e14 Isolate return values from helpers
Do the appropriate equality check for three cases:
(1) helpers in text nodes
(2) helpers in element attributes
(3) helpers in dynamic template inclusion

Also, assert that helpers passed to template inclusion indeed
return components or null.
2014-01-26 11:52:26 -08:00
Avital Oliver
63319c8e6d Test that helper return values are isolated
More specifically, a helper re-runs and its return value hash't
changed, nothing should change in the DOM. Test this for:
(1) helpers in text nodes
(2) helpers in element attributes
(3) helpers in dynamic template inclusion
2014-01-26 11:52:26 -08:00
David Greenspan
0e0d8f218c Better error message for <circle r={{r}}/>
Now we tell you to put a space before the slash.  HTML allows slash as part of a bare attribute value.
2014-01-25 19:41:21 -08:00
David Glasser
d30bb79498 Ensure crossbar callbacks not called after stop
Hopefully fixes #1767.
2014-01-23 23:23:30 -08:00
David Glasser
fca2966676 Simplify crossbar by making it synchronous
All existing listener callbacks were already calling complete()
synchronously, so this should not be a functional change.

This allows us to also eliminate the callback from crossbar.fire().

This in turn allows us to eliminate the `proxy_write` in
Meteor.refresh. The only purpose of that write was to keep the current
write fence open until fire's async callback got called; now that fire
works synchronously, it's not necessary!  (This relies on the fact that
write fences never get armed while they are the current write fence,
which now has an assertion.)
2014-01-23 23:13:42 -08:00
David Glasser
d868325b83 Don't yield in oplog entry handler 2014-01-23 21:53:51 -08:00
David Glasser
8eca012c32 Minor optimizations to new _IdMaps 2014-01-23 21:28:21 -08:00
David Greenspan
fc955af5c0 Require template tag kw args to be at end 2014-01-23 20:45:09 -08:00
David Glasser
a7d10d650d Update Node to 0.10.25. Remove bug workaround. 2014-01-23 12:15:29 -08:00
Avital Oliver
23405cd5d4 Don't allow templates named 'content'
Trying to include them later with {{> content}}
fails. We could disallow the other built-ins,
eg 'if' and 'elseContent' but sounds less likely
that users will try to define templates with
those names, and this simple change lets us
not duplicate code.
2014-01-22 19:35:44 -08:00
Slava Kim
8b28f1fab6 Change phase and register a fact in the same place 2014-01-22 17:45:24 -08:00
Avital Oliver
91cce88c91 Make {{#if content}} work.
This lets you check whether a template was invoked via
inclusion or as a block helper. An example is the
api_box template in docs.
2014-01-22 16:34:45 -08:00
Slava Kim
2952edc73a Merge branch 'oplog-selector-modifier-operators' into devel
- Cache the matchingDocument on Matcher
- Minor cosmetic changes
2014-01-22 15:30:39 -08:00
Slava Kim
9971e5b298 Glasser's comments
- use startsWith for strings rather than x.indexOf(y) && x[y.length] === '.'
- more comments with examples
- consistent naming isSimple => simpleRange, simpleInequality, etc
2014-01-22 15:29:13 -08:00
Slava Kim
1be7e5a900 Initialize Matcher._matchingDocument in the constructor.
To declare it explicitly to humans and JITs.
2014-01-22 14:17:19 -08:00
Slava Kim
4c3c1389ef Some additional facts about oplog-driver 2014-01-21 18:51:08 -08:00
Slava Kim
1c7e222c63 Refactor matchingDocument into separate method on Matcher's prototype, cache it. 2014-01-21 14:02:23 -08:00
Sashko Stubailo
45ccc12970 Make default accounts-ui styling simpler/flatter 2014-01-21 13:57:52 -08:00
David Greenspan
0a93fa46b9 Organize spacebars-compiler.js 2014-01-21 12:28:23 -08:00
David Greenspan
d0388dc30b Make spacebars compiler shorter 2014-01-20 19:48:24 -08:00
David Greenspan
7be0250867 Fix CRLF handling in HTML tokenizer
We would choke on CR line endings, because we didn't implement the preprocessing step of converting CR(LF)? to LF.  Now we correctly convert (or ignore) CR inside tags, in text nodes, in attributes, and in comments.
2014-01-20 19:19:07 -08:00
David Greenspan
b2522aa1b4 re-org getSpecialTag into TemplateTag
...specifically into TemplateTag.parseCompleteTag.

Also document TemplateTag more.
2014-01-20 15:52:12 -08:00
Avital Oliver
f440a117ef Test an edge-case with template inclusion in {{#markdown}} 2014-01-20 14:24:28 -08:00
David Greenspan
0a6e9c984f Make tag.toText slightly more correct 2014-01-20 14:17:29 -08:00
David Greenspan
6a4fb19a80 Use correct node.toHTML arguments
for clarity
2014-01-20 14:07:45 -08:00
Avital Oliver
b3e31fc968 Merge branch 'shark-make-docs-work' into shark 2014-01-20 00:16:45 -08:00
Avital Oliver
04ec013674 Allow including templates within {{#markdown}}
The docs app now works. Fixes #1736.
2014-01-20 00:14:17 -08:00