Skip to content
Merged
Show file tree
Hide file tree
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
11 changes: 4 additions & 7 deletions packages/linkify-react/src/linkify-react.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { tokenize, Options, options } from 'linkifyjs';
import { tokenize, Options } from 'linkifyjs';

/**
* Given a string, converts to an array of valid React components
Expand All @@ -10,7 +10,6 @@ import { tokenize, Options, options } from 'linkifyjs';
* @returns {React.ReactNodeArray}
*/
function stringToElements(str, opts, meta) {

const tokens = tokenize(str);
const elements = [];

Expand All @@ -28,7 +27,7 @@ function stringToElements(str, opts, meta) {
if (!('key' in rendered.props)) {
// Ensure generated element has unique key
const key = `__linkify-el-${meta.elementId++}`;
const props = options.assign({ key }, rendered.props);
const props = Object.assign({ key }, rendered.props);
rendered = React.cloneElement(rendered, props);
}
elements.push(rendered);
Expand Down Expand Up @@ -60,9 +59,7 @@ function linkifyReactElement(element, opts, meta) {
// ensure that we always generate unique element IDs for keys
children.push.apply(children, stringToElements(child, opts, meta));
} else if (React.isValidElement(child)) {
if (typeof child.type === 'string'
&& opts.ignoreTags.indexOf(child.type.toUpperCase()) >= 0
) {
if (typeof child.type === 'string' && opts.ignoreTags.indexOf(child.type.toUpperCase()) >= 0) {
// Don't linkify this element
children.push(child);
} else {
Expand All @@ -76,7 +73,7 @@ function linkifyReactElement(element, opts, meta) {

// Set a default unique key, copy over remaining props
const key = `__linkify-el-${meta.elementId++}`;
const newProps = options.assign({ key }, element.props);
const newProps = Object.assign({ key }, element.props);
return React.cloneElement(element, newProps, children);
}

Expand Down
15 changes: 0 additions & 15 deletions packages/linkifyjs/src/assign.mjs

This file was deleted.

5 changes: 2 additions & 3 deletions packages/linkifyjs/src/fsm.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* Finite State Machine generation utilities
*/
import assign from './assign.mjs';

/**
* @template T
Expand Down Expand Up @@ -273,7 +272,7 @@ State.prototype = {
templateState = state.go(input);
if (templateState) {
nextState = new State();
assign(nextState.j, templateState.j);
Object.assign(nextState.j, templateState.j);
nextState.jr.push.apply(nextState.jr, templateState.jr);
nextState.jd = templateState.jd;
nextState.t = templateState.t;
Expand All @@ -285,7 +284,7 @@ State.prototype = {
// Ensure newly token is in the same groups as the old token
if (groups) {
if (nextState.t && typeof nextState.t === 'string') {
const allFlags = assign(flagsForToken(nextState.t, groups), flags);
const allFlags = Object.assign(flagsForToken(nextState.t, groups), flags);
addToGroups(t, allFlags, groups);
} else if (flags) {
addToGroups(t, flags, groups);
Expand Down
3 changes: 1 addition & 2 deletions packages/linkifyjs/src/multi.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { COLON, LOCALHOST } from './text.mjs';
import { defaults } from './options.mjs';
import assign from './assign.mjs';

/******************************************************************************
Multi-Tokens
Expand Down Expand Up @@ -163,7 +162,7 @@ MultiToken.prototype = {
attributes.rel = rel;
}
if (attrs) {
assign(attributes, attrs);
Object.assign(attributes, attrs);
}

return { tagName, attributes, content, eventListeners };
Expand Down
8 changes: 2 additions & 6 deletions packages/linkifyjs/src/options.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import assign from './assign.mjs';

/**
* An object where each key is a valid DOM Event Name such as `click` or `focus`
* and each value is an event handler function.
Expand Down Expand Up @@ -109,9 +107,9 @@ export const defaults = {
* Similar to render option
*/
export function Options(opts, defaultRender = null) {
let o = assign({}, defaults);
let o = Object.assign({}, defaults);
if (opts) {
o = assign(o, opts instanceof Options ? opts.o : opts);
o = Object.assign(o, opts instanceof Options ? opts.o : opts);
}

// Ensure all ignored tags are uppercase
Expand Down Expand Up @@ -214,8 +212,6 @@ Options.prototype = {
},
};

export { assign };

function noop(val) {
return val;
}
3 changes: 1 addition & 2 deletions packages/linkifyjs/src/scanner.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { State, addToGroups, tr, ts, tt } from './fsm.mjs';
import * as fsm from './fsm.mjs';
import * as tk from './text.mjs';
import * as re from './regexp.mjs';
import assign from './assign.mjs';

const CR = '\r'; // carriage-return character
const LF = '\n'; // line-feed character
Expand Down Expand Up @@ -203,7 +202,7 @@ export function init(customSchemes = []) {

// Set default transition for start state (some symbol)
Start.jd = new State(tk.SYM);
return { start: Start, tokens: assign({ groups }, tk) };
return { start: Start, tokens: Object.assign({ groups }, tk) };
}

/**
Expand Down