mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
feat(input): default autocomplete/autocorrect=off, fix autofocus
Related: #5480
This commit is contained in:
@@ -199,13 +199,13 @@ export function hasFocusedTextInput() {
|
||||
return false;
|
||||
}
|
||||
|
||||
const skipInputAttrsReg = /^(value|checked|disabled|type|class|style|id)$/i
|
||||
const skipInputAttrsReg = /^(value|checked|disabled|type|class|style|id|autofocus|autocomplete|autocorrect)$/i
|
||||
export function copyInputAttributes(srcElement, destElement) {
|
||||
// copy attributes from one element to another
|
||||
// however, skip over a few of them as they're already
|
||||
// handled in the angular world
|
||||
let attrs = srcElement.attributes;
|
||||
for (let i = 0; i < attrs.length; i++) {
|
||||
var attrs = srcElement.attributes;
|
||||
for (var i = 0; i < attrs.length; i++) {
|
||||
var attr = attrs[i];
|
||||
if (!skipInputAttrsReg.test(attr.name)) {
|
||||
destElement.setAttribute(attr.name, attr.value);
|
||||
|
||||
@@ -15,6 +15,10 @@ export function run() {
|
||||
expect(util.isTrueProperty(' true ')).toBe(true);
|
||||
});
|
||||
|
||||
it('should be true from string "on"', () => {
|
||||
expect(util.isTrueProperty(true)).toBe(true);
|
||||
});
|
||||
|
||||
it('should be true from empty string ""', () => {
|
||||
expect(util.isTrueProperty('')).toBe(true);
|
||||
expect(util.isTrueProperty(' ')).toBe(true);
|
||||
@@ -29,6 +33,10 @@ export function run() {
|
||||
expect(util.isTrueProperty(false)).toBe(false);
|
||||
});
|
||||
|
||||
it('should be false from string "off"', () => {
|
||||
expect(util.isTrueProperty(true)).toBe(true);
|
||||
});
|
||||
|
||||
it('should be false from null', () => {
|
||||
expect(util.isTrueProperty(null)).toBe(false);
|
||||
});
|
||||
|
||||
@@ -113,7 +113,7 @@ export const isArray = Array.isArray;
|
||||
export const isTrueProperty = function(val: any): boolean {
|
||||
if (typeof val === 'string') {
|
||||
val = val.toLowerCase().trim();
|
||||
return (val === 'true' || val === '');
|
||||
return (val === 'true' || val === 'on' || val === '');
|
||||
}
|
||||
return !!val;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user