未验证 提交 abaa85a3 编写于 作者: M Mouad Debbar 提交者: GitHub

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

上级 2a8f6dca
......@@ -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,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册