Skip to content

Commit

Permalink
[change] Tag determination based on recommendation by @spicyj
Browse files Browse the repository at this point in the history
Fix semicolon

Fix another semicolon
  • Loading branch information
nhunzaker committed Mar 20, 2015
1 parent 66b3a0a commit 930646f
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 13 deletions.
8 changes: 6 additions & 2 deletions src/browser/ui/ReactDOMComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ ReactDOMComponent.Mixin = {
var mountImages = this.mountChildren(
childrenToUse,
transaction,
context
assign({}, context, { _svgTextDecendant: this._tag === 'text' })
);
ret = mountImages.join('');
}
Expand Down Expand Up @@ -342,7 +342,11 @@ ReactDOMComponent.Mixin = {
updateComponent: function(transaction, prevElement, nextElement, context) {
assertValidProps(this, this._currentElement.props);
this._updateDOMProperties(prevElement.props, transaction);
this._updateDOMChildren(prevElement.props, transaction, context);
this._updateDOMChildren(
prevElement.props,
transaction,
assign({}, context, { _svgTextDecendant: this._tag === 'text' })
);
},

/**
Expand Down
11 changes: 7 additions & 4 deletions src/browser/ui/ReactDOMTextComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ assign(ReactDOMTextComponent.prototype, {
* @return {string} Markup for this text node.
* @internal
*/
mountComponent: function(rootID, transaction, context, parentTag) {
mountComponent: function(rootID, transaction, context) {
this._rootNodeID = rootID;
var escapedText = escapeTextContentForBrowser(this._stringText);

Expand All @@ -76,10 +76,13 @@ assign(ReactDOMTextComponent.prototype, {
}

// SVG <text> elements use <tspan> rather than <span>
var tag = parentTag === 'text' ? 'tspan' : 'span';
var attrs = DOMPropertyOperations.createMarkupForID(rootID);
var tag = context._svgTextDecendant ? 'tspan' : 'span';

return `<${ tag } ${ attrs }>${ escapedText }</${ tag }>`;
return (
'<' + tag + ' ' + DOMPropertyOperations.createMarkupForID(rootID) + '>' +
escapedText +
'</' + tag + '>'
);
},

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ describe('ReactSVGText', function() {

expect(label.textContent).toEqual('first second');
expect(children[0].tagName).toEqual('tspan');
})
});

});
6 changes: 2 additions & 4 deletions src/core/ReactMultiChild.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,7 @@ var ReactMultiChild = {
child,
rootID,
transaction,
context,
this._tag
context
);
child._mountIndex = index;
mountImages.push(mountImage);
Expand Down Expand Up @@ -402,8 +401,7 @@ var ReactMultiChild = {
child,
rootID,
transaction,
context,
this._tag
context
);
child._mountIndex = index;
this.createChild(child, mountImage);
Expand Down
4 changes: 2 additions & 2 deletions src/core/ReactReconciler.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ var ReactReconciler = {
* @final
* @internal
*/
mountComponent: function(internalInstance, rootID, transaction, context, parentTag) {
var markup = internalInstance.mountComponent(rootID, transaction, context, parentTag);
mountComponent: function(internalInstance, rootID, transaction, context) {
var markup = internalInstance.mountComponent(rootID, transaction, context);
if (__DEV__) {
ReactElementValidator.checkAndWarnForMutatedProps(
internalInstance._currentElement
Expand Down

0 comments on commit 930646f

Please sign in to comment.