mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[web] Proper support for text field's obscureText (#13722)
This commit is contained in:
parent
2a8f6dca60
commit
abaa85a394
@ -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);
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user