-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19890 from tienifr/fix/19848-autofill-input
fix: autofill is not a valid selector
- Loading branch information
Showing
3 changed files
with
23 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
import isSelectorSupported from './isSelectorSupported'; | ||
|
||
/** | ||
* Check the input is auto filled or not | ||
* @param {Object} input | ||
* @return {Boolean} | ||
*/ | ||
export default function isInputAutoFilled(input) { | ||
if (!input.matches) return false; | ||
return input.matches(':-webkit-autofill') || input.matches(':autofill'); | ||
if (isSelectorSupported(':autofill')) { | ||
return input.matches(':-webkit-autofill') || input.matches(':autofill'); | ||
} | ||
return input.matches(':-webkit-autofill'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* Check platform supports the selector or not | ||
* @param {String} selector | ||
* @return {Boolean} | ||
*/ | ||
export default function isSelectorSupported(selector) { | ||
try { | ||
document.querySelector(selector); | ||
return true; | ||
} catch (error) { | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Native platforms do not support the selector | ||
export default function isSelectorSupported() { | ||
return false; | ||
} |