Socket
Socket
Sign inDemoInstall

linkify-react

Package Overview
Dependencies
4
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.0.0 to 4.0.1

32

dist/linkify-react.cjs.js

@@ -31,6 +31,7 @@ 'use strict';

* @param {Options} opts
* @param {{ [elementId: string]: number }} meta
* @returns {React.ReactNodeArray}
*/
function stringToElements(str, opts, parentElementId) {
function stringToElements(str, opts, meta) {
var tokens = linkifyjs.tokenize(str);

@@ -41,7 +42,7 @@ var elements = [];

var token = tokens[i];
var defaultKey = "__linkify-el-" + parentElementId + "-" + i;
if (token.t === 'nl' && opts.get('nl2br')) {
var key = "__linkify-el-" + meta.elementId++;
elements.push(React__namespace.createElement('br', {
key: defaultKey
key: key
}));

@@ -56,4 +57,6 @@ } else if (!token.isLink || !opts.check(token)) {

// Ensure generated element has unique key
var _key = "__linkify-el-" + meta.elementId++;
var props = linkifyjs.options.assign({
key: defaultKey
key: _key
}, rendered.props);

@@ -75,3 +78,3 @@ rendered = React__namespace.cloneElement(rendered, props);

* @param {Options} opts
* @param {number} elementId
* @param {{ [elementId: string]: number }} meta
* @returns {React.ReactElement<P, T>}

@@ -81,7 +84,3 @@ */

function linkifyReactElement(element, opts, elementId) {
if (elementId === void 0) {
elementId = 0;
}
function linkifyReactElement(element, opts, meta) {
if (React__namespace.Children.count(element.props.children) === 0) {

@@ -96,3 +95,3 @@ // No need to clone if the element had no children

// ensure that we always generate unique element IDs for keys
children.push.apply(children, stringToElements(child, opts, elementId));
children.push.apply(children, stringToElements(child, opts, meta));
} else if (React__namespace.isValidElement(child)) {

@@ -103,3 +102,3 @@ if (typeof child.type === 'string' && opts.ignoreTags.indexOf(child.type.toUpperCase()) >= 0) {

} else {
children.push(linkifyReactElement(child, opts, elementId + 1));
children.push(linkifyReactElement(child, opts, meta));
}

@@ -112,4 +111,5 @@ } else {

var key = "__linkify-el-" + meta.elementId++;
var newProps = linkifyjs.options.assign({
key: "__linkify-el-" + elementId
key: key
}, element.props);

@@ -134,3 +134,3 @@ return React__namespace.cloneElement(element, newProps, children);

content = _ref.content;
attributes.key = "__linkify-lnk-" + ++linkId;
attributes.key = "__linkify-lnk-" + linkId++;

@@ -159,5 +159,7 @@ if (attributes.class) {

var element = React__namespace.createElement(as, newProps, children);
return linkifyReactElement(element, opts, 0);
return linkifyReactElement(element, opts, {
elementId: 0
});
};
module.exports = Linkify;

@@ -9,6 +9,7 @@ import * as React from 'react';

* @param {Options} opts
* @param {{ [elementId: string]: number }} meta
* @returns {React.ReactNodeArray}
*/
function stringToElements(str, opts, parentElementId) {
function stringToElements(str, opts, meta) {
var tokens = tokenize(str);

@@ -19,7 +20,7 @@ var elements = [];

var token = tokens[i];
var defaultKey = "__linkify-el-" + parentElementId + "-" + i;
if (token.t === 'nl' && opts.get('nl2br')) {
var key = "__linkify-el-" + meta.elementId++;
elements.push(React.createElement('br', {
key: defaultKey
key: key
}));

@@ -34,4 +35,6 @@ } else if (!token.isLink || !opts.check(token)) {

// Ensure generated element has unique key
var _key = "__linkify-el-" + meta.elementId++;
var props = options.assign({
key: defaultKey
key: _key
}, rendered.props);

@@ -53,3 +56,3 @@ rendered = React.cloneElement(rendered, props);

* @param {Options} opts
* @param {number} elementId
* @param {{ [elementId: string]: number }} meta
* @returns {React.ReactElement<P, T>}

@@ -59,7 +62,3 @@ */

function linkifyReactElement(element, opts, elementId) {
if (elementId === void 0) {
elementId = 0;
}
function linkifyReactElement(element, opts, meta) {
if (React.Children.count(element.props.children) === 0) {

@@ -74,3 +73,3 @@ // No need to clone if the element had no children

// ensure that we always generate unique element IDs for keys
children.push.apply(children, stringToElements(child, opts, elementId));
children.push.apply(children, stringToElements(child, opts, meta));
} else if (React.isValidElement(child)) {

@@ -81,3 +80,3 @@ if (typeof child.type === 'string' && opts.ignoreTags.indexOf(child.type.toUpperCase()) >= 0) {

} else {
children.push(linkifyReactElement(child, opts, elementId + 1));
children.push(linkifyReactElement(child, opts, meta));
}

@@ -90,4 +89,5 @@ } else {

var key = "__linkify-el-" + meta.elementId++;
var newProps = options.assign({
key: "__linkify-el-" + elementId
key: key
}, element.props);

@@ -112,3 +112,3 @@ return React.cloneElement(element, newProps, children);

content = _ref.content;
attributes.key = "__linkify-lnk-" + ++linkId;
attributes.key = "__linkify-lnk-" + linkId++;

@@ -137,5 +137,7 @@ if (attributes.class) {

var element = React.createElement(as, newProps, children);
return linkifyReactElement(element, opts, 0);
return linkifyReactElement(element, opts, {
elementId: 0
});
};
export { Linkify as default };

@@ -29,6 +29,7 @@ var Linkify = (function (React, linkifyjs) {

* @param {Options} opts
* @param {{ [elementId: string]: number }} meta
* @returns {React.ReactNodeArray}
*/
function stringToElements(str, opts, parentElementId) {
function stringToElements(str, opts, meta) {
var tokens = linkifyjs.tokenize(str);

@@ -39,7 +40,7 @@ var elements = [];

var token = tokens[i];
var defaultKey = "__linkify-el-" + parentElementId + "-" + i;
if (token.t === 'nl' && opts.get('nl2br')) {
var key = "__linkify-el-" + meta.elementId++;
elements.push(React__namespace.createElement('br', {
key: defaultKey
key: key
}));

@@ -54,4 +55,6 @@ } else if (!token.isLink || !opts.check(token)) {

// Ensure generated element has unique key
var _key = "__linkify-el-" + meta.elementId++;
var props = linkifyjs.options.assign({
key: defaultKey
key: _key
}, rendered.props);

@@ -73,3 +76,3 @@ rendered = React__namespace.cloneElement(rendered, props);

* @param {Options} opts
* @param {number} elementId
* @param {{ [elementId: string]: number }} meta
* @returns {React.ReactElement<P, T>}

@@ -79,7 +82,3 @@ */

function linkifyReactElement(element, opts, elementId) {
if (elementId === void 0) {
elementId = 0;
}
function linkifyReactElement(element, opts, meta) {
if (React__namespace.Children.count(element.props.children) === 0) {

@@ -94,3 +93,3 @@ // No need to clone if the element had no children

// ensure that we always generate unique element IDs for keys
children.push.apply(children, stringToElements(child, opts, elementId));
children.push.apply(children, stringToElements(child, opts, meta));
} else if (React__namespace.isValidElement(child)) {

@@ -101,3 +100,3 @@ if (typeof child.type === 'string' && opts.ignoreTags.indexOf(child.type.toUpperCase()) >= 0) {

} else {
children.push(linkifyReactElement(child, opts, elementId + 1));
children.push(linkifyReactElement(child, opts, meta));
}

@@ -110,4 +109,5 @@ } else {

var key = "__linkify-el-" + meta.elementId++;
var newProps = linkifyjs.options.assign({
key: "__linkify-el-" + elementId
key: key
}, element.props);

@@ -132,3 +132,3 @@ return React__namespace.cloneElement(element, newProps, children);

content = _ref.content;
attributes.key = "__linkify-lnk-" + ++linkId;
attributes.key = "__linkify-lnk-" + linkId++;

@@ -157,3 +157,5 @@ if (attributes.class) {

var element = React__namespace.createElement(as, newProps, children);
return linkifyReactElement(element, opts, 0);
return linkifyReactElement(element, opts, {
elementId: 0
});
};

@@ -160,0 +162,0 @@

@@ -1,1 +0,1 @@

var Linkify=function(e,n){"use strict";function r(e){if(e&&e.__esModule)return e;var n=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var t=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,t.get?t:{enumerable:!0,get:function(){return e[r]}})}})),n.default=e,Object.freeze(n)}var t=r(e);function i(e,r,a){if(void 0===a&&(a=0),0===t.Children.count(e.props.children))return e;var s=[];t.Children.forEach(e.props.children,(function(e){"string"==typeof e?s.push.apply(s,function(e,r,i){for(var a=n.tokenize(e),s=[],o=0;o<a.length;o++){var l=a[o],c="__linkify-el-"+i+"-"+o;if("nl"===l.t&&r.get("nl2br"))s.push(t.createElement("br",{key:c}));else if(l.isLink&&r.check(l)){var p=r.render(l);if(!("key"in p.props)){var u=n.options.assign({key:c},p.props);p=t.cloneElement(p,u)}s.push(p)}else s.push(l.toString())}return s}(e,r,a)):t.isValidElement(e)?"string"==typeof e.type&&r.ignoreTags.indexOf(e.type.toUpperCase())>=0?s.push(e):s.push(i(e,r,a+1)):s.push(e)}));var o=n.options.assign({key:"__linkify-el-"+a},e.props);return t.cloneElement(e,o,s)}return function(e){var r=0,a={key:"__linkify-wrapper"};for(var s in e)"options"!==s&&"as"!==s&&"tagName"!==s&&"children"!==s&&(a[s]=e[s]);var o=new n.Options(e.options,(function(e){var n=e.tagName,i=e.attributes,a=e.content;return i.key="__linkify-lnk-"+ ++r,i.class&&(i.className=i.class,delete i.class),t.createElement(n,i,a)})),l=e.as||e.tagName||t.Fragment||"span",c=e.children;return i(t.createElement(l,a,c),o,0)}}(React,linkify);
var Linkify=function(e,n){"use strict";function t(e){if(e&&e.__esModule)return e;var n=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}})),n.default=e,Object.freeze(n)}var r=t(e);function i(e,t,a){if(0===r.Children.count(e.props.children))return e;var l=[];r.Children.forEach(e.props.children,(function(e){"string"==typeof e?l.push.apply(l,function(e,t,i){for(var a=n.tokenize(e),l=[],s=0;s<a.length;s++){var o=a[s];if("nl"===o.t&&t.get("nl2br")){var c="__linkify-el-"+i.elementId++;l.push(r.createElement("br",{key:c}))}else if(o.isLink&&t.check(o)){var p=t.render(o);if(!("key"in p.props)){var f="__linkify-el-"+i.elementId++,u=n.options.assign({key:f},p.props);p=r.cloneElement(p,u)}l.push(p)}else l.push(o.toString())}return l}(e,t,a)):r.isValidElement(e)?"string"==typeof e.type&&t.ignoreTags.indexOf(e.type.toUpperCase())>=0?l.push(e):l.push(i(e,t,a)):l.push(e)}));var s="__linkify-el-"+a.elementId++,o=n.options.assign({key:s},e.props);return r.cloneElement(e,o,l)}return function(e){var t=0,a={key:"__linkify-wrapper"};for(var l in e)"options"!==l&&"as"!==l&&"tagName"!==l&&"children"!==l&&(a[l]=e[l]);var s=new n.Options(e.options,(function(e){var n=e.tagName,i=e.attributes,a=e.content;return i.key="__linkify-lnk-"+t++,i.class&&(i.className=i.class,delete i.class),r.createElement(n,i,a)})),o=e.as||e.tagName||r.Fragment||"span",c=e.children;return i(r.createElement(o,a,c),s,{elementId:0})}}(React,linkify);
{
"name": "linkify-react",
"version": "4.0.0",
"version": "4.0.1",
"description": "React element interface for linkifyjs",

@@ -5,0 +5,0 @@ "main": "dist/linkify-react.cjs.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with โšก๏ธ by Socket Inc