MCPcopy Create free account
hub / github.com/angular/components / setValue

Method setValue

src/material/input/testing/input-harness.ts:125–139  ·  view source on GitHub ↗

* Sets the value of the input. The value will be set by simulating * keypresses that correspond to the given value.

(newValue: string)

Source from the content-addressed store, hash-verified

123 * keypresses that correspond to the given value.
124 */
125 async setValue(newValue: string): Promise<void> {
126 const inputEl = await this.host();
127 await inputEl.clear();
128 // We don't want to send keys for the value if the value is an empty
129 // string in order to clear the value. Sending keys with an empty string
130 // still results in unnecessary focus events.
131 if (newValue) {
132 await inputEl.sendKeys(newValue);
133 }
134
135 // Some input types won't respond to key presses (e.g. `color`) so to be sure that the
136 // value is set, we also set the property after the keyboard sequence. Note that we don't
137 // want to do it before, because it can cause the value to be entered twice.
138 await inputEl.setInputValue(newValue);
139 }
140}

Callers 2

input.spec.tsFile · 0.45

Calls 3

clearMethod · 0.65
sendKeysMethod · 0.65
setInputValueMethod · 0.65

Tested by

no test coverage detected