Skip to content

Commit

Permalink
Remove babel optional runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
tasti committed Jun 2, 2015
1 parent 9830de4 commit d38b780
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 26 deletions.
35 changes: 17 additions & 18 deletions dist/Linkify.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
'use strict';

var _inherits = require('babel-runtime/helpers/inherits')['default'];

var _createClass = require('babel-runtime/helpers/create-class')['default'];
Object.defineProperty(exports, '__esModule', {
value: true
});

var _classCallCheck = require('babel-runtime/helpers/class-call-check')['default'];
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();

var _Object$defineProperty = require('babel-runtime/core-js/object/define-property')['default'];
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

var _Object$assign = require('babel-runtime/core-js/object/assign')['default'];
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }

var _interopRequireDefault = require('babel-runtime/helpers/interop-require-default')['default'];

_Object$defineProperty(exports, '__esModule', {
value: true
});
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }

var _react = require('react');

Expand Down Expand Up @@ -44,15 +40,18 @@ var Linkify = (function (_React$Component) {
if (urlIdx === -1 && emailIdx === -1) {
elements.push(string);
return this.parseStringHelper('', elements);
} else if (urlIdx === -1) {
urlIdx = emailIdx + 1;
} else if (emailIdx === -1) {
emailIdx = urlIdx + 1;
}

var idx = undefined,
regex = undefined;
if (urlIdx < emailIdx) {

if (urlIdx === -1) {
idx = emailIdx;
regex = this.props.emailRegex;
} else if (emailIdx === -1) {
idx = urlIdx;
regex = this.props.urlRegex;
} else if (urlIdx < emailIdx) {
idx = urlIdx;
regex = this.props.urlRegex;
} else {
Expand All @@ -70,7 +69,7 @@ var Linkify = (function (_React$Component) {
}

// Shallow update values that specified the match
var props = {};
var props = { key: Linkify.uniqueKey() };
for (var key in this.props.properties) {
var val = this.props.properties[key];
if (val === Linkify.MATCH) {
Expand All @@ -80,7 +79,7 @@ var Linkify = (function (_React$Component) {
props[key] = val;
}

elements.push(_react2['default'].createElement(this.props.component, _Object$assign(props, { key: Linkify.uniqueKey() }), match));
elements.push(_react2['default'].createElement(this.props.component, props, match));

return this.parseStringHelper(string.substring(idx + len), elements);
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"urlify"
],
"scripts": {
"build": "babel --stage 0 --optional runtime src/Linkify.jsx -o dist/Linkify.js",
"build": "babel --stage 0 src/Linkify.jsx -o dist/Linkify.js",
"test": "BABEL_JEST_STAGE=0 jest"
},
"devDependencies": {
Expand Down
17 changes: 10 additions & 7 deletions src/Linkify.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,17 @@ class Linkify extends React.Component {
if ((urlIdx === -1) && (emailIdx === -1)) {
elements.push(string);
return this.parseStringHelper('', elements);
} else if (urlIdx === -1) {
urlIdx = emailIdx + 1;
} else if (emailIdx === -1) {
emailIdx = urlIdx + 1;
}

let idx, regex;
if (urlIdx < emailIdx) {

if (urlIdx === -1) {
idx = emailIdx;
regex = this.props.emailRegex;
} else if (emailIdx === -1) {
idx = urlIdx;
regex = this.props.urlRegex;
} else if (urlIdx < emailIdx) {
idx = urlIdx;
regex = this.props.urlRegex;
} else { // Email has precedence over url when equal
Expand All @@ -58,7 +61,7 @@ class Linkify extends React.Component {
}

// Shallow update values that specified the match
let props = {};
let props = {key: Linkify.uniqueKey()};
for (let key in this.props.properties) {
let val = this.props.properties[key];
if (val === Linkify.MATCH) {
Expand All @@ -70,7 +73,7 @@ class Linkify extends React.Component {

elements.push(React.createElement(
this.props.component,
Object.assign(props, {key: Linkify.uniqueKey()}),
props,
match
));

Expand Down

0 comments on commit d38b780

Please sign in to comment.