Commit Graph

104 Commits

Author SHA1 Message Date
Sashko Stubailo
a6d4e98407 Revert "Tests for Template.currentData and Template.parentData"
This reverts commit f2840103ca.

Conflicts:
	packages/spacebars-tests/template_tests.html
	packages/spacebars-tests/template_tests.js
2015-03-09 13:39:44 -07:00
Sashko Stubailo
c0aab1e8d3 Template-level subscriptions 2015-02-11 18:10:33 -08:00
Avital Oliver
f2840103ca Tests for Template.currentData and Template.parentData
A recent change fixed the behavior of `Template.currentData`
and `Template.parentData` in event handlers and helpers.
These are tests for the new, correct behavior.

(The old behavior read the data of the template instance.
The new behavior read the data context around the DOM node
where the event or helper ran)
2015-01-26 16:44:50 -08:00
Sashko Stubailo
7ec339e5b8 Add tests for #3540 2015-01-23 16:57:13 -08:00
David Greenspan
ab92f117ae Expand fix for #3130
If you Blaze.remove a View that is a template rendered by Blaze.renderWithData, or included with an implicit “with” as in `{{> myTemplate someData}}`, Blaze will now remove the DOM of the template, and also remove the implicit “with” (in both cases).

As background, Blaze.remove only works on Views that were attached directly under a DOM element, not inside another View.  Blaze.render always attaches the resulting View directly under a DOM element, but Blaze.renderWithData creates a “with” View around the template View.  Previously, you could Blaze.remove the “with” View (which is returned by renderWithData), but if you got access to the template’s View some other way and tried to remove it directly, nothing would happen.  Now, the correct thing happens (the View is destroyed and the DOM is removed).

In the future, we should consider whether Blaze.remove should work on arbitrary Views, not just Views attached under a DOM element.
2014-12-09 13:17:12 -08:00
Slava Kim
ebce6c46aa Add a blaze test for #3130 2014-12-08 17:05:05 -08:00
David Greenspan
a3f3b7b690 Add tests for old-style helper back-compat 2014-09-24 19:04:17 -07:00
David Greenspan
fe5c61104f Fix falsy helpers (like 0) 2014-09-24 17:02:20 -07:00
David Greenspan
855284559a Back-compat tests 2014-09-18 17:29:04 -07:00
David Greenspan
e7cf040177 Rename {{> UI.*}} to Template; remove UI uses
Rename inclusion macros (with back-compat) to: Template.dynamic, Template.contentBlock, Template.elseBlock.

Update all uses and mentions of UI in the repo, unless they are there for back-compat or testing reasons.

To do: Run unit tests.  Update docs for UI.dynamic.  Document Template.contentBlock and Template.elseBlock.
2014-09-17 17:24:25 -07:00
David Greenspan
7e44526ab9 Test for Avi’s fix to input elements (c2cf671)
Needs IE 8 version of test
2014-08-15 17:12:46 -07:00
David Greenspan
75c30ef073 Fix scope of UI.contentBlock argument
Eric Dobbertin’s bug
2014-07-28 12:23:54 -07:00
Emily Stark
1ac501784a Add test for this.autorun 2014-07-25 15:05:38 -07:00
David Greenspan
0cc2624c59 Fix #2339 (dynamic attributes on textareas) 2014-07-25 14:23:44 -07:00
David Greenspan
adeb649bf6 Fix Blaze.currentView in event handlers
with test
2014-07-25 13:57:47 -07:00
David Greenspan
2e191e0b09 Add regression tests for d56d9da
Make sure inclusions with one path segment like “..” and “foo” (where foo is in the data context) don’t cause the enclosing template to re-render when the data context changes.
2014-07-16 15:06:20 -07:00
David Greenspan
57465b00c2 Handle textarea edge case slightly more gracefully
and tests
2014-07-13 11:30:32 -07:00
David Greenspan
e970d5381d Merge branch 'blaze-refactor' into devel
Conflicts:
	packages/spacebars-tests/template_tests.html
	packages/spacebars-tests/template_tests.js
	packages/ui/render.js
2014-07-10 16:29:20 -07:00
Emily Stark
3d058ad5ab Make <a> tags SVG elements when they have xlink:href.
Fixes #2178.
2014-07-09 11:40:22 -07:00
David Greenspan
d8c36e4605 Moar tests (and focus/blur shenanigans) 2014-07-07 12:24:06 -07:00
David Greenspan
072ef0a23d Test focus and blur event cleanup 2014-07-07 11:56:11 -07:00
David Greenspan
1a8136e4ef Test autorun cleanup and jQuery removal 2014-07-03 14:46:06 -07:00
Avital Oliver
b21d87d142 Merge branch 'blaze-refactor' into blaze-views
Conflicts:
	packages/spacebars-tests/template_tests.html
	packages/spacebars-tests/template_tests.js
	packages/ui/package.js
	packages/ui/ui.js
2014-06-30 20:14:58 -07:00
Avital Oliver
ab21aa2e7c re-implement UI._templateInstance() 2014-06-30 19:50:32 -07:00
Avital Oliver
33cd3a5344 Port UI.getElementData 2014-06-27 13:40:06 -07:00
Avital Oliver
e9e7237e8f Port UI.render, UI.renderWithData, UI.insert
UI.render and UI.renderWithData now return a DOMRange.
We've never quite documented what the return value of
these functions is, other than "you can pass it to
UI.insert", which is still true.

Also ported the tests by moving them into the spacebars-tests
package, so that they use a template rather than the
component/htmljs API. This has the added benefit of
making the tests less brittle to changes in internals.
2014-06-25 17:07:32 -07:00
David Greenspan
4cfe3838aa Test destroyed callback better
We weren’t actually testing that templates removed by control flow (like #each) get their destroyed callback called.

This test should make it to devel regardless of the fate of this branch.
2014-06-24 13:49:45 -07:00
David Greenspan
095b3a26c6 Merge remote-tracking branch 'origin/devel' into blaze-refactor
Conflicts:
	packages/spacebars-tests/template_tests.js
	packages/ui/base.js
	packages/ui/dombackend.js
	packages/ui/dombackend_tests.js
	packages/ui/domrange.js
	packages/ui/domrange_tests.js
	packages/ui/each.js
	packages/ui/render.js
	packages/ui/render_tests.js
2014-06-23 10:56:55 -07:00
Emily Stark
dc2b03aee6 Tentative maybe fix for UI hooks on nested domranges. 2014-06-18 17:03:46 -07:00
Emily Stark
b84c7662f3 Fix UI._templateInstance() to look at surrounding template.
Previously we were using the current component to retrieve the template
instance, but what we actually want is the template instance of the
surrounding component that is a template.
2014-06-17 16:58:54 -07:00
Matthew Arbesfeld
6b48630160 Adds UI._parentData(n) method in template helpers.
This method returns the parent data context which surrounds the
helper call. This mirrors the effect of {{..}} in Spacebars. So
UI._parentData(2) is equivalent to {{../..}}.
2014-06-17 14:02:17 -07:00
David Greenspan
832f3bab02 Test the interpretation of event map selectors
If you listen on “div p”, for example, both the div and the p have to be in the template.
2014-06-10 14:51:58 -07:00
David Greenspan
5c23ec2e36 Merge remote-tracking branch 'origin/devel' into blaze-refactor 2014-06-09 19:58:19 -07:00
Emily Stark
f6cb154770 Make sure autoruns for {{#with}} get cleaned up.
Related to #2145, #2023, #2031.
2014-06-09 19:13:23 -07:00
Emily Stark
ba0770a908 Merge remote-tracking branch 'origin/devel' into blaze-refactor
Conflicts:
	packages/html-tools/tokenize.js
	packages/spacebars-compiler/package.js
	packages/spacebars-compiler/spacebars-compiler.js
	packages/spacebars-tests/template_tests.html
	packages/spacebars-tests/template_tests.js
	packages/spacebars/package.js
	packages/spacebars/spacebars-runtime.js
	packages/ui/domrange.js
	packages/ui/render_tests.js
2014-06-06 14:05:44 -07:00
Avital Oliver
af32d49c2b Remove tests for {{#isolate}} and {{#constant}}
We're no longer going to support these. We supported
them originally on Blaze to make the upgrade process
from Spark easier, but now there's no more need
for them.
2014-06-06 11:57:27 -07:00
Avital Oliver
0e881d28a1 Test that would have caught a recent test failure
The bug itself was fixed in e5118295d3
2014-06-06 11:46:09 -07:00
Emily Stark
58a14da1a1 Fix double-removal of elements.
Change the unused `viaBackend` flag to `elementsAlreadyRemoved`, and set
the flag in two places: 1. when we remove things from a DomRange
immediately after calling `removeNode`, and 2. when DomRange is notified
that an element has been removed via DomBackend.

The motivation is that re-enabling undocumented animation hooks revealed
that we were trying to remove elements twice: once from `removeNode`,
and once from `nodeRemoved` (via `membersRemoved`).
2014-06-04 09:35:23 -07:00
Emily Stark
65b76b2bc9 Add UI._templateInstance() 2014-06-02 13:51:13 -07:00
Emily Stark
24e3c3e0e1 Expose underscored animation hooks and add a test 2014-05-28 12:12:15 -07:00
Emily Stark
b63328c4e9 Add _nestInCurrentComputation flag to UI.render.
Internally, Blaze sometimes relies on `UI.render`'s autoruns nesting
within the current computation, but it's often the case that callers
don't want `UI.render`'s autoruns to be stopped when the outer
computation is invalidated. This change fixes a bug in {{#each}}: if
`addedAt` ran inside a `Deps.autorun`, and then the outer computation
was invalidated, the corresponding item would stop updating because the
autoruns set up by `UI.render` would be stopped.

Fixes #2156.
2014-05-27 16:43:44 -07:00
David Greenspan
3df4e95845 Merge branch 'devel' into blaze-refactor
Conflicts:
	packages/spacebars-tests/template_tests.js
	packages/ui/domrange.js
2014-05-27 13:38:59 -07:00
Emily Stark
9ebf963be6 Add a test for cleaning up event handlers when template is destroyed 2014-05-15 13:55:55 -07:00
David Greenspan
d96ee0eab2 Rewrite Spacebars optimizer to use Visitors 2014-04-24 12:24:03 -07:00
Emily Stark
6b95113d99 Make Blaze refuse to render javascript: URLs.
Call UI._allowJavascriptUrls() to enable them again. In the future, we
should have a per-element way to enable this, not a global
configuration, and maybe someday even a similar feature for other
policies (like enabling or disabling inline event handlers).
2014-04-20 17:28:55 -07:00
Avital Oliver
95aaa99312 Fix {{#with}} over a data context that is mutated
In `Spacebars.With` we embox the data context. This commit makes
that emboxing happen modulo `safeEquals`. So now if you
{{#with}} over a helper that returns an object, any time
that helper gets invalidated we re-run the computations in the block.

Fixes #2046 (though notably that example mutates the data context
from within a helper, which could lead to other types of unintended
behavior; it's probably in this particular example -- the data context
just gets added properties)
2014-04-19 00:29:34 -07:00
David Greenspan
f7bbbe8ff7 Merge remote-tracking branch 'origin/pr/2061' into devel
Conflicts:
	packages/spacebars-tests/template_tests.html
	packages/spacebars-tests/template_tests.js
2014-04-17 12:22:32 -07:00
Avital Oliver
ca46407e5d Properly clean up autoruns on UI.toHTML.
The prior commit didn't stop components of type
`Spacebars.With` correctly.
2014-04-17 03:00:05 -07:00
Avital Oliver
797a080e7f Fix UI.toHTML on templates containing {{#with}}
Originally reported at
https://github.com/meteor/meteor/issues/2007#issuecomment-40530195
2014-04-17 03:00:05 -07:00
Matthew Arbesfeld
f68fe75ded Add support for block comments in Spacebars 2014-04-15 19:58:10 -04:00