[web] Proper support for text field's obscureText (#13722)

This commit is contained in:
Mouad Debbar 2019-11-06 13:20:23 -08:00 committed by GitHub
parent 2a8f6dca60
commit abaa85a394
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 0 deletions

View File

@ -369,6 +369,9 @@ class TextEditingElement {
void _initDomElement(InputConfiguration inputConfig) {
domElement = inputConfig.inputType.createDomElement();
inputConfig.inputType.configureDomElement(domElement);
if (inputConfig.obscureText) {
domElement.setAttribute('type', 'password');
}
_setStaticStyleAttributes(domElement);
owner._setDynamicStyleAttributes(domElement);
domRenderer.glassPaneElement.append(domElement);

View File

@ -85,6 +85,7 @@ void main() {
// Now the editing element should have focus.
expect(document.activeElement, input);
expect(editingElement.domElement, input);
expect(input.getAttribute('type'), null);
// Input is appended to the glass pane.
expect(domRenderer.glassPaneElement.contains(editingElement.domElement),
@ -99,6 +100,25 @@ void main() {
expect(document.activeElement, document.body);
});
test('Knows how to create password fields', () {
final InputConfiguration config = InputConfiguration(
inputType: EngineInputType.text,
inputAction: 'TextInputAction.done',
obscureText: true,
);
editingElement.enable(
config,
onChange: trackEditingState,
onAction: trackInputAction,
);
expect(document.getElementsByTagName('input'), hasLength(1));
final InputElement input = document.getElementsByTagName('input')[0];
expect(editingElement.domElement, input);
expect(input.getAttribute('type'), 'password');
editingElement.disable();
});
test('Can read editing state correctly', () {
editingElement.enable(
singlelineConfig,