react-from-dom
Advanced tools
Comparing version 0.4.2 to 0.5.0
@@ -104,2 +104,3 @@ var __assign = (this && this.__assign) || function () { | ||
export function convertFromNode(input, options) { | ||
var _a; | ||
if (options === void 0) { options = {}; } | ||
@@ -109,3 +110,3 @@ if (!input || !(input instanceof Node)) { | ||
} | ||
var _a = options.actions, actions = _a === void 0 ? [] : _a, _b = options.index, index = _b === void 0 ? 0 : _b, _c = options.level, level = _c === void 0 ? 0 : _c; | ||
var _b = options.actions, actions = _b === void 0 ? [] : _b, _c = options.index, index = _c === void 0 ? 0 : _c, _d = options.level, level = _d === void 0 ? 0 : _d; | ||
var node = input; | ||
@@ -145,5 +146,5 @@ var key = level + "-" + index; | ||
// textnode | ||
var nodeText = node.nodeValue.toString(); | ||
var nodeText = ((_a = node.nodeValue) === null || _a === void 0 ? void 0 : _a.toString()) || ''; | ||
/* istanbul ignore else */ | ||
if (/^\s+$/.test(nodeText)) { | ||
if (/^\s+$/.test(nodeText) && !/[\u202F\u00A0]/.test(nodeText)) { | ||
return null; | ||
@@ -150,0 +151,0 @@ } |
@@ -107,2 +107,3 @@ "use strict"; | ||
function convertFromNode(input, options) { | ||
var _a; | ||
if (options === void 0) { options = {}; } | ||
@@ -112,3 +113,3 @@ if (!input || !(input instanceof Node)) { | ||
} | ||
var _a = options.actions, actions = _a === void 0 ? [] : _a, _b = options.index, index = _b === void 0 ? 0 : _b, _c = options.level, level = _c === void 0 ? 0 : _c; | ||
var _b = options.actions, actions = _b === void 0 ? [] : _b, _c = options.index, index = _c === void 0 ? 0 : _c, _d = options.level, level = _d === void 0 ? 0 : _d; | ||
var node = input; | ||
@@ -148,5 +149,5 @@ var key = level + "-" + index; | ||
// textnode | ||
var nodeText = node.nodeValue.toString(); | ||
var nodeText = ((_a = node.nodeValue) === null || _a === void 0 ? void 0 : _a.toString()) || ''; | ||
/* istanbul ignore else */ | ||
if (/^\s+$/.test(nodeText)) { | ||
if (/^\s+$/.test(nodeText) && !/[\u202F\u00A0]/.test(nodeText)) { | ||
return null; | ||
@@ -153,0 +154,0 @@ } |
{ | ||
"name": "react-from-dom", | ||
"version": "0.4.2", | ||
"version": "0.5.0", | ||
"description": "Convert HTML/XML source code or DOM nodes to React elements", | ||
"author": "Gil Barbara <gilbarbara@gmail.com>", | ||
"keywords": [ | ||
"string", | ||
"DOM", | ||
"converter", | ||
"react", | ||
"component" | ||
], | ||
"license": "MIT", | ||
"repository": { | ||
@@ -23,52 +31,44 @@ "type": "git", | ||
"sideEffects": false, | ||
"license": "MIT", | ||
"keywords": [ | ||
"string", | ||
"DOM", | ||
"converter", | ||
"react", | ||
"component" | ||
], | ||
"peerDependencies": { | ||
"react": "^15.0.0 || ^16.0.0" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"@gilbarbara/tsconfig": "^0.1.0", | ||
"@size-limit/preset-small-lib": "^4.5.1", | ||
"@types/enzyme": "^3.10.5", | ||
"@size-limit/preset-small-lib": "^4.6.0", | ||
"@types/enzyme": "^3.10.7", | ||
"@types/enzyme-adapter-react-16": "^1.0.6", | ||
"@types/jest": "^26.0.0", | ||
"@types/node": "^14.0.13", | ||
"@types/react": "^16.9.38", | ||
"@types/jest": "^26.0.14", | ||
"@types/node": "^14.11.2", | ||
"@types/react": "^16.9.49", | ||
"@types/react-dom": "^16.9.8", | ||
"@typescript-eslint/eslint-plugin": "^3.3.0", | ||
"@typescript-eslint/parser": "^3.3.0", | ||
"@typescript-eslint/eslint-plugin": "^4.3.0", | ||
"@typescript-eslint/parser": "^4.3.0", | ||
"del-cli": "^3.0.1", | ||
"enzyme": "^3.11.0", | ||
"enzyme-adapter-react-16": "^1.15.2", | ||
"eslint": "^6.8.0", | ||
"enzyme-adapter-react-16": "^1.15.5", | ||
"eslint": "^7.10.0", | ||
"eslint-config-airbnb": "^18.2.0", | ||
"eslint-config-prettier": "^6.11.0", | ||
"eslint-plugin-import": "^2.21.2", | ||
"eslint-config-prettier": "^6.12.0", | ||
"eslint-plugin-import": "^2.22.1", | ||
"eslint-plugin-jsx-a11y": "^6.3.1", | ||
"eslint-plugin-prettier": "^3.1.4", | ||
"eslint-plugin-react": "^7.20.0", | ||
"eslint-plugin-react-hooks": "^4.0.4", | ||
"fetch-mock": "^9.10.1", | ||
"husky": "^4.2.5", | ||
"is-ci-cli": "^2.1.1", | ||
"jest": "^26.0.1", | ||
"eslint-plugin-react": "^7.21.2", | ||
"eslint-plugin-react-hooks": "^4.1.2", | ||
"fetch-mock": "^9.10.7", | ||
"husky": "^4.3.0", | ||
"is-ci-cli": "^2.1.2", | ||
"jest": "^26.4.2", | ||
"jest-chain": "^1.1.5", | ||
"jest-enzyme": "^7.1.2", | ||
"jest-extended": "^0.11.5", | ||
"jest-watch-typeahead": "^0.6.0", | ||
"prettier": "^2.0.5", | ||
"react": "^16.12.0", | ||
"jest-watch-typeahead": "^0.6.1", | ||
"prettier": "^2.1.2", | ||
"react": "^16.13.1", | ||
"react-dom": "^16.13.1", | ||
"repo-tools": "^0.2.0", | ||
"serve": "^11.3.2", | ||
"size-limit": "^4.5.1", | ||
"start-server-and-test": "^1.11.0", | ||
"ts-jest": "^26.1.0", | ||
"typescript": "^3.9.5" | ||
"size-limit": "^4.6.0", | ||
"ts-jest": "^26.4.0", | ||
"typescript": "^4.0.3" | ||
}, | ||
@@ -79,5 +79,5 @@ "scripts": { | ||
"build:esm": "tsc -m es6 --outDir esm", | ||
"clean": "del lib/* && del esm/*", | ||
"watch:cjs": "npm run build:cjs -- -w", | ||
"watch:esm": "npm run build:esm -- -w", | ||
"clean": "del lib/* && del esm/*", | ||
"test": "is-ci \"test:coverage\" \"test:watch\"", | ||
@@ -84,0 +84,0 @@ "test:coverage": "jest --coverage --bail", |
@@ -169,6 +169,6 @@ /* eslint-disable @typescript-eslint/no-use-before-define */ | ||
// textnode | ||
const nodeText = node.nodeValue!.toString(); | ||
const nodeText = node.nodeValue?.toString() || ''; | ||
/* istanbul ignore else */ | ||
if (/^\s+$/.test(nodeText)) { | ||
if (/^\s+$/.test(nodeText) && !/[\u202F\u00A0]/.test(nodeText)) { | ||
return null; | ||
@@ -216,3 +216,3 @@ } | ||
const parser = new DOMParser(); | ||
const doc = parser.parseFromString(input, type as SupportedType); | ||
const doc = parser.parseFromString(input, type as DOMParserSupportedType); | ||
const node = doc.querySelector(selector); | ||
@@ -219,0 +219,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
97621
37
1870