Skip to content

Commit

Permalink
Avoid rendering <a> element
Browse files Browse the repository at this point in the history
This has caused many issues, when an <a> element is created in this component there will be no way to support links, as nested <a> elements is offensive in the eyes of HTML.

Closes mui#2178, mui#1979, mui#1823
  • Loading branch information
alitaheri committed Dec 30, 2015
1 parent 947ad7d commit 24e43ea
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/enhanced-button.jsx
Expand Up @@ -195,9 +195,12 @@ const EnhancedButton = React.createClass({
};
const buttonChildren = this._createButtonChildren();

// Provides backward compatibity. Added to support wrapping around <a> element.
const targetLinkElement = buttonProps.hasOwnProperty('href') ? 'a' : 'span';

return React.isValidElement(containerElement) ?
React.cloneElement(containerElement, buttonProps, buttonChildren) :
React.createElement(linkButton ? 'a' : containerElement, buttonProps, buttonChildren);
React.createElement(linkButton ? targetLinkElement : containerElement, buttonProps, buttonChildren);

},

Expand Down

0 comments on commit 24e43ea

Please sign in to comment.