all files / addon/components/polaris-button/ link.js

100% Statements 2/2
100% Branches 4/4
100% Functions 2/2
100% Lines 2/2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31                                                         
import { computed } from '@ember/object';
import BaseComponent from './base';
import mapEventToAction from '../../utils/map-event-to-action';
 
export default BaseComponent.extend({
  tagName: 'a',
  attributeBindings: [
    'url:href',
    'dataPolarisUnstyled:data-polaris-unstyled',
    'target',
    'rel',
  ],
 
  dataPolarisUnstyled: 'true',
 
  target: computed('external', function() {
    return this.get('external') ? '_blank' : null;
  }),
 
  rel: computed('external', function() {
    return this.get('external') ? 'noopener noreferrer' : null;
  }).readOnly(),
 
  /**
   * Action handlers.
   */
  //  Allow click to perform its default action.
  click: mapEventToAction('onClick', { preventDefault: false }),
});