@wordpress/dom
Advanced tools
Comparing version 2.13.0 to 2.13.1
@@ -418,18 +418,6 @@ /** | ||
export function isTextField(element) { | ||
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; | ||
} | ||
var nodeName = element.nodeName, | ||
contentEditable = element.contentEditable; | ||
var nonTextInputs = ['button', 'checkbox', 'hidden', 'file', 'radio', 'image', 'range', 'reset', 'submit', 'number']; | ||
return nodeName === 'INPUT' && !nonTextInputs.includes(element.type) || nodeName === 'TEXTAREA' || contentEditable === 'true'; | ||
} | ||
@@ -436,0 +424,0 @@ /** |
@@ -452,18 +452,6 @@ "use strict"; | ||
function isTextField(element) { | ||
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; | ||
} | ||
var nodeName = element.nodeName, | ||
contentEditable = element.contentEditable; | ||
var nonTextInputs = ['button', 'checkbox', 'hidden', 'file', 'radio', 'image', 'range', 'reset', 'submit', 'number']; | ||
return nodeName === 'INPUT' && !nonTextInputs.includes(element.type) || nodeName === 'TEXTAREA' || contentEditable === 'true'; | ||
} | ||
@@ -470,0 +458,0 @@ /** |
{ | ||
"name": "@wordpress/dom", | ||
"version": "2.13.0", | ||
"version": "2.13.1", | ||
"description": "DOM utilities module for WordPress.", | ||
@@ -33,3 +33,3 @@ "author": "The WordPress Contributors", | ||
}, | ||
"gitHead": "381a42b62e157d0e7fd6366cc51b0f5725990044" | ||
"gitHead": "862bb53a4af8aa5852a22445b5d12591d5500e52" | ||
} |
@@ -451,21 +451,20 @@ /** | ||
export function isTextField( element ) { | ||
try { | ||
const { nodeName, selectionStart, contentEditable } = element; | ||
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; | ||
} | ||
const { nodeName, contentEditable } = element; | ||
const nonTextInputs = [ | ||
'button', | ||
'checkbox', | ||
'hidden', | ||
'file', | ||
'radio', | ||
'image', | ||
'range', | ||
'reset', | ||
'submit', | ||
'number', | ||
]; | ||
return ( | ||
( nodeName === 'INPUT' && ! nonTextInputs.includes( element.type ) ) || | ||
nodeName === 'TEXTAREA' || | ||
contentEditable === 'true' | ||
); | ||
} | ||
@@ -472,0 +471,0 @@ |
@@ -110,5 +110,8 @@ /** | ||
'checkbox', | ||
'image', | ||
'hidden', | ||
'file', | ||
'radio', | ||
'image', | ||
'range', | ||
'reset', | ||
'submit', | ||
@@ -122,3 +125,9 @@ ]; | ||
*/ | ||
const TEXT_INPUT_TYPES = [ 'text', 'password', 'search', 'url' ]; | ||
const TEXT_INPUT_TYPES = [ | ||
'text', | ||
'password', | ||
'search', | ||
'url', | ||
'email', | ||
]; | ||
@@ -125,0 +134,0 @@ it( 'should return false for non-text input elements', () => { |
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
242455
3109