mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Fix spacebars optimizer
It was accidentally disabled, and it tried to optimize SVG, invalidly.
This commit is contained in:
@@ -186,11 +186,14 @@ HTML.EmitCode = function (value) {
|
||||
this.value = value;
|
||||
};
|
||||
|
||||
HTML.isTagEnsured = function (t) {
|
||||
return HTML.isKnownElement(t) || HTML.isKnownSVGElement(t);
|
||||
};
|
||||
|
||||
(function () {
|
||||
for (var i = 0; i < HTML.knownElementNames.length; i++)
|
||||
HTML.ensureTag(HTML.knownElementNames[i]);
|
||||
|
||||
for (var i = 0; i < HTML.knownSVGElementNames.length; i++)
|
||||
HTML.ensureTag(HTML.knownSVGElementNames[i]);
|
||||
|
||||
})();
|
||||
|
||||
@@ -507,9 +507,10 @@ var optimize = function (tree) {
|
||||
return null;
|
||||
} else if (node instanceof HTML.Tag) {
|
||||
|
||||
if (node.tagName === 'TEXTAREA') {
|
||||
if (node.tagName === 'TEXTAREA' || (! HTML.isKnownElement(node.tagName))) {
|
||||
// optimizing into a TEXTAREA's RCDATA would require being a little
|
||||
// more clever.
|
||||
// more clever. foreign elements like SVG can't be stringified for
|
||||
// innerHTML.
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -935,19 +936,20 @@ Spacebars.compile = function (input, options) {
|
||||
};
|
||||
|
||||
Spacebars.codeGen = function (parseTree, options) {
|
||||
var tree = parseTree;
|
||||
|
||||
if (isTemplate)
|
||||
// optimizing fragments would require being smarter about whether we are
|
||||
// in a TEXTAREA, say.
|
||||
tree = optimize(tree);
|
||||
|
||||
tree = replaceSpecials(tree);
|
||||
|
||||
// is this a template, rather than a block passed to
|
||||
// a block helper, say
|
||||
var isTemplate = (options && options.isTemplate);
|
||||
|
||||
var tree = parseTree;
|
||||
|
||||
if (isTemplate) {
|
||||
// optimizing fragments would require being smarter about whether we are
|
||||
// in a TEXTAREA, say.
|
||||
tree = optimize(tree);
|
||||
}
|
||||
|
||||
tree = replaceSpecials(tree);
|
||||
|
||||
var code = '(function () { var self = this; ';
|
||||
if (isTemplate) {
|
||||
// support `{{> content}}` and `{{> elseContent}}` with
|
||||
|
||||
@@ -44,7 +44,7 @@ HTML.Tag.prototype.toJS = function (options) {
|
||||
}
|
||||
|
||||
var tagSymbol = this.tagName;
|
||||
if ((this instanceof HTML.Tag) && ! HTML.isKnownElement(tagSymbol))
|
||||
if ((this instanceof HTML.Tag) && ! HTML.isTagEnsured(tagSymbol))
|
||||
tagSymbol = 'HTML.getTag(' + toJSLiteral(tagSymbol) + ')';
|
||||
else
|
||||
tagSymbol = 'HTML.' + tagSymbol;
|
||||
|
||||
Reference in New Issue
Block a user