mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
get rid of EmptyComponent
not really empty since now Component renders its content by default
This commit is contained in:
@@ -784,7 +784,7 @@ Spacebars.compile = function (inputString, options) {
|
||||
var argCode =
|
||||
codeGenArgs(block.openTag.args, funcInfo,
|
||||
extraArgs)[0];
|
||||
bodyLines.push('buf.component(function () { return ((' + nameCode + ') || EmptyComponent).create(' + argCode +
|
||||
bodyLines.push('buf.component(function () { return ((' + nameCode + ') || Component).create(' + argCode +
|
||||
'); });');
|
||||
} else {
|
||||
switch (tag.type) {
|
||||
@@ -792,7 +792,7 @@ Spacebars.compile = function (inputString, options) {
|
||||
var nameCode = codeGenPath(tag.path, funcInfo, true);
|
||||
var argCode =
|
||||
codeGenArgs(tag.args, funcInfo, {})[0];
|
||||
bodyLines.push('buf.component(function () { return ((' + nameCode + ') || EmptyComponent).create(' + argCode +
|
||||
bodyLines.push('buf.component(function () { return ((' + nameCode + ') || Component).create(' + argCode +
|
||||
'); });');
|
||||
break;
|
||||
case 'DOUBLE':
|
||||
|
||||
@@ -421,7 +421,7 @@ Tinytest.add("spacebars - compiler", function (test) {
|
||||
|
||||
'function (buf) {',
|
||||
' var self = this;',
|
||||
' buf.component(function () { return ((self.lookup("foo")) || EmptyComponent).create({"data": Spacebars.call(self.lookup("bar")), "baz": Spacebars.call(Spacebars.index(self.lookup("x"), "y"))}); });',
|
||||
' buf.component(function () { return ((self.lookup("foo")) || Component).create({"data": Spacebars.call(self.lookup("bar")), "baz": Spacebars.call(Spacebars.index(self.lookup("x"), "y"))}); });',
|
||||
'}');
|
||||
|
||||
run('{{#foo.bar}}{{/foo.baz}}', {fail: 'Close tag'});
|
||||
@@ -431,7 +431,7 @@ Tinytest.add("spacebars - compiler", function (test) {
|
||||
|
||||
'function (buf) {',
|
||||
' var self = this;',
|
||||
' buf.component(function () { return ((self.lookup("if")) || EmptyComponent).create({"data": Spacebars.call(self.lookup("foo")), "content": Component.extend({render: function (buf) {',
|
||||
' buf.component(function () { return ((self.lookup("if")) || Component).create({"data": Spacebars.call(self.lookup("foo")), "content": Component.extend({render: function (buf) {',
|
||||
' buf.text("bar");',
|
||||
' }})}); });',
|
||||
'}');
|
||||
@@ -440,7 +440,7 @@ Tinytest.add("spacebars - compiler", function (test) {
|
||||
|
||||
'function (buf) {',
|
||||
' var self = this;',
|
||||
' buf.component(function () { return ((self.lookup("if")) || EmptyComponent).create({"data": Spacebars.call(self.lookup("foo")), "content": Component.extend({render: function (buf) {',
|
||||
' buf.component(function () { return ((self.lookup("if")) || Component).create({"data": Spacebars.call(self.lookup("foo")), "content": Component.extend({render: function (buf) {',
|
||||
' buf.text("bar");',
|
||||
' }}), "elseContent": Component.extend({render: function (buf) {',
|
||||
' buf.text("baz");',
|
||||
|
||||
@@ -693,10 +693,6 @@ Component.extend = function (options) {
|
||||
return newClass;
|
||||
};
|
||||
|
||||
// @export EmptyComponent
|
||||
EmptyComponent = Component.extend({});
|
||||
// (might be some optimizations possible in the future)
|
||||
|
||||
// @export TextComponent
|
||||
TextComponent = Component.extend({
|
||||
render: function (buf) {
|
||||
|
||||
@@ -85,9 +85,8 @@ Each = Component.extend({
|
||||
|
||||
if (items.empty()) {
|
||||
buf.component(function () {
|
||||
return (self.getArg('elseContent') ||
|
||||
EmptyComponent).create(
|
||||
{ data: self.getArg('data') });
|
||||
return (self.getArg('elseContent') || Component).create(
|
||||
{ data: self.getArg('data') });
|
||||
}, { key: 'elseContent' });
|
||||
} else {
|
||||
items.forEach(function (doc, id) {
|
||||
@@ -132,8 +131,7 @@ Each = Component.extend({
|
||||
var childId = self._itemChildId(id);
|
||||
if (self.items.size() === 0) {
|
||||
// made empty
|
||||
var elseClass = self.getArg('elseContent') ||
|
||||
EmptyComponent;
|
||||
var elseClass = self.getArg('elseContent') || Component;
|
||||
var comp = elseClass.create({data: self.getArg('data')});
|
||||
self.replaceChild(childId, comp, 'elseContent');
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user