Commit Graph

14 Commits

Author SHA1 Message Date
David Greenspan
1e7b91feaa Fix some tests 2014-04-22 15:55:56 -07:00
David Greenspan
5e85c32ea6 Move asciiLowerCase to html-tools 2014-03-03 15:51:35 -08:00
David Greenspan
f6c766ae06 Start html.js refactor; case-fold at compile time
- Start shrinking html.js down to the 150-line file it can be
- Move "proper case" logic to the template compiler; the tagName of an HTMLjs tag is now in proper case.  This is both for better performance and reduced size and complexity of runtime code (i.e. blaze.js).
- Start moving html-tools to the HTMLTools namespace
2014-03-03 15:51:35 -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
a6b3a431b2 further internal docs and cleanup 2014-01-03 17:27:17 -08:00
David Greenspan
7710a77270 start of htmljs README 2014-01-02 16:56:31 -08:00
David Greenspan
556870983e more tests and fixes
- moved tojs.js into spacebars

Some failing tests in `spacebars-tests` and `ui`

```
meteor test-packages spacebars htmljs html spacebars-tests ui
```
2013-12-09 23:12:12 -08:00
David Greenspan
87921cf178 Redo the HTML representation; needs debugging
Puts HTML.Tag, toHTML, and toJS in the "htmljs" package.
Introduces toText for textareas and attributes.
Changes dynamic attribute representation.
Instances of HTML.Tag, HTML.CharRef, etc. are now "instanceof".

Once this code seems to work, we'll move packages around further.
- "htmljs" is the runtime; can even take out "tocode.js"
- "html-tools" (new package) takes over for "html".

Then, port the tests.
2013-12-09 22:23:27 -08:00
David Glasser
bc8f251cd1 oops, remove debugging code 2013-07-25 18:54:42 -07:00
David Glasser
e4c568b1e1 Merge exports list with package variables in slice JSON.
This implies that all exports are package variables, which made underscore,
jquery, and htmljs (which explicitly assigned to fields on the global variable)
break. We now properly encapsulate these packages (except for window.jQuery,
which we let sneak out because bootstrap wants it).  This means that packages
that want _ need to use underscore, and packages that want $ need to use jquery.
Also, you can't use _ in minimongo $where any more (matching mongod).
2013-07-25 18:54:42 -07:00
Geoff Schmidt
76c57526f7 rework public API for defining tests 2012-03-02 05:22:40 -08:00
Geoff Schmidt
cab5afbb91 move test reporting functions out of globals 2012-03-02 03:57:30 -08:00
Nick Martin
7f133d37b5 Move htmljs test. This was missed as it happened at the same time as the test migration. 2012-01-27 20:03:59 -08:00