Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add target="" support for button component #23

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions lib/componentFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,21 @@ module.exports = function(element) {
// <button>
case this.components.button:
var expander = '';
var attrs = [];

// If we have the href attribute we can create an anchor for the inner of the button;
// If we have the href attribute we add it to the attributes array
if (element.attr('href')) {
inner = format('<a href="%s">%s</a>', element.attr('href'), inner);
attrs.push(format('href="%s"', element.attr('href')));
}

// If we have the target attribute we add it to the attributes array
if (element.attr('target')) {
attrs.push(format('target="%s"', element.attr('target')));
}

// If we have the href attribute or the target we can create an anchor for the inner of the button
if (element.attr('href') || element.attr('target')) {
inner = format('<a %s>%s</a>', attrs.join(' '), inner);
}

// If the button is expanded, it needs a <center> tag around the content
Expand Down