@wordpress/dom
Advanced tools
Comparing version 2.0.2 to 2.0.3
@@ -428,6 +428,18 @@ /** | ||
export function isTextField(element) { | ||
var nodeName = element.nodeName, | ||
selectionStart = element.selectionStart, | ||
contentEditable = element.contentEditable; | ||
return nodeName === 'INPUT' && selectionStart !== null || nodeName === 'TEXTAREA' || contentEditable === 'true'; | ||
try { | ||
var nodeName = element.nodeName, | ||
selectionStart = element.selectionStart, | ||
contentEditable = element.contentEditable; | ||
return nodeName === 'INPUT' && selectionStart !== null || nodeName === 'TEXTAREA' || contentEditable === 'true'; | ||
} catch (error) { | ||
// Safari throws an exception when trying to get `selectionStart` | ||
// on non-text <input> elements (which, understandably, don't | ||
// have the text selection API). We catch this via a try/catch | ||
// block, as opposed to a more explicit check of the element's | ||
// input types, because of Safari's non-standard behavior. This | ||
// also means we don't have to worry about the list of input | ||
// types that support `selectionStart` changing as the HTML spec | ||
// evolves over time. | ||
return false; | ||
} | ||
} | ||
@@ -434,0 +446,0 @@ /** |
@@ -457,6 +457,18 @@ "use strict"; | ||
function isTextField(element) { | ||
var nodeName = element.nodeName, | ||
selectionStart = element.selectionStart, | ||
contentEditable = element.contentEditable; | ||
return nodeName === 'INPUT' && selectionStart !== null || nodeName === 'TEXTAREA' || contentEditable === 'true'; | ||
try { | ||
var nodeName = element.nodeName, | ||
selectionStart = element.selectionStart, | ||
contentEditable = element.contentEditable; | ||
return nodeName === 'INPUT' && selectionStart !== null || nodeName === 'TEXTAREA' || contentEditable === 'true'; | ||
} catch (error) { | ||
// Safari throws an exception when trying to get `selectionStart` | ||
// on non-text <input> elements (which, understandably, don't | ||
// have the text selection API). We catch this via a try/catch | ||
// block, as opposed to a more explicit check of the element's | ||
// input types, because of Safari's non-standard behavior. This | ||
// also means we don't have to worry about the list of input | ||
// types that support `selectionStart` changing as the HTML spec | ||
// evolves over time. | ||
return false; | ||
} | ||
} | ||
@@ -463,0 +475,0 @@ /** |
{ | ||
"name": "@wordpress/dom", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"description": "DOM utilities module for WordPress.", | ||
@@ -29,3 +29,3 @@ "author": "The WordPress Contributors", | ||
}, | ||
"gitHead": "0aa5c4340f57a69ab935f9e819d74958aad2e022" | ||
"gitHead": "ce02ee2a1749b9b5564cb8483f6c8f24cf8a3871" | ||
} |
@@ -436,9 +436,21 @@ /** | ||
export function isTextField( element ) { | ||
const { nodeName, selectionStart, contentEditable } = element; | ||
try { | ||
const { nodeName, selectionStart, contentEditable } = element; | ||
return ( | ||
( nodeName === 'INPUT' && selectionStart !== null ) || | ||
( nodeName === 'TEXTAREA' ) || | ||
contentEditable === 'true' | ||
); | ||
return ( | ||
( nodeName === 'INPUT' && selectionStart !== null ) || | ||
( nodeName === 'TEXTAREA' ) || | ||
contentEditable === 'true' | ||
); | ||
} catch ( error ) { | ||
// Safari throws an exception when trying to get `selectionStart` | ||
// on non-text <input> elements (which, understandably, don't | ||
// have the text selection API). We catch this via a try/catch | ||
// block, as opposed to a more explicit check of the element's | ||
// input types, because of Safari's non-standard behavior. This | ||
// also means we don't have to worry about the list of input | ||
// types that support `selectionStart` changing as the HTML spec | ||
// evolves over time. | ||
return false; | ||
} | ||
} | ||
@@ -445,0 +457,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
185898
2446
1