Skip to content

Commit

Permalink
Merge branch 'mdn:main' into timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
skyclouds2001 authored Oct 5, 2024
2 parents 43d748a + 4f0efd0 commit ef8af4a
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 7 deletions.
70 changes: 70 additions & 0 deletions files/en-us/web/api/htmloutputelement/defaultvalue/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
title: "HTMLOutputElement: defaultValue property"
short-title: defaultValue
slug: Web/API/HTMLOutputElement/defaultValue
page-type: web-api-instance-property
browser-compat: api.HTMLOutputElement.defaultValue
---

{{ APIRef("HTML DOM") }}

The **`defaultValue`** property of the {{DOMxRef("HTMLOutputElement")}} interface represents the default text content of this {{htmlelement("output")}} element. Getting and setting this value is equivalent to getting and setting {{domxref("Node.textContent", "textContent")}} on the {{htmlelement("output")}}.

## Value

A string.

## Examples

In the example below, the `defaultValue` still returns the value originally written in the HTML. Changes to {{domxref("HTMLOutputElement.value", "value")}} will not affect the `defaultValue` or its `textContent` in the DOM.

```html
<fieldset>
<legend>Add two numbers</legend>
<p>
<input type="number" id="operand1" value="5" aria-label="First number" />
+
<input type="number" id="operand2" value="7" aria-label="Second number" />
=
<output
id="result"
for="operand1 operand2"
aria-live="polite"
aria-controls="output"
>12</output
>
</p>
</fieldset>
<pre id="logs" aria-live="polite"></pre>
```

```js
const logs = document.getElementById("logs");
const operand1 = document.getElementById("operand1");
const operand2 = document.getElementById("operand2");
const result = document.getElementById("result");

function updateResult() {
result.value = operand1.valueAsNumber + operand2.valueAsNumber;
logs.innerText = `result.defaultValue: ${result.defaultValue}\nresult.value: ${result.value}`;
}

operand1.addEventListener("input", updateResult);
operand2.addEventListener("input", updateResult);
updateResult();
```

{{EmbedLiveSample("examples", "", "150")}}

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- {{HTMLElement("output")}}
- {{DOMXref("HTMLOutputElement.value")}}
37 changes: 37 additions & 0 deletions files/en-us/web/api/htmloutputelement/htmlfor/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
title: "HTMLOutputElement: htmlFor property"
short-title: htmlFor
slug: Web/API/HTMLOutputElement/htmlFor
page-type: web-api-instance-property
browser-compat: api.HTMLOutputElement.htmlFor
---

{{ APIRef("HTML DOM") }}

The **`htmlFor`** property of the {{DOMxRef("HTMLOutputElement")}} interface is a string containing a space-separated list of other elements' `id`s, indicating that those elements contributed input values to (or otherwise affected) the calculation. It reflects the [`for`](/en-US/docs/Web/HTML/Element/output#for) attribute of the {{HTMLElement("output")}} element.

## Value

A string.

## Examples

```js
const outputElem = document.getElementById("result");
for (const id of outputElem.htmlFor.split(" ")) {
const elem = document.getElementById(id);
elem.style.outline = "2px solid red";
}
```

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- {{HTMLElement("output")}}
2 changes: 0 additions & 2 deletions files/en-us/web/api/requestinit/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,6 @@ You can also construct a `Request` with a `RequestInit`, and pass the `Request`
- : The request must be a [simple request](/en-US/docs/Web/HTTP/CORS#simple_requests), which restricts the headers that may be set to {{glossary("CORS-safelisted request header", "CORS-safelisted request headers")}}, and restricts methods to `GET`, `HEAD`, and `POST`.
- `navigate`
- : Used only by HTML navigation. A `navigate` request is created only while navigating between documents.
- `websocket`
- : Used only when establishing a [WebSocket](/en-US/docs/Web/API/WebSockets_API) connection.

See [Making cross-origin requests](/en-US/docs/Web/API/Fetch_API/Using_Fetch#making_cross-origin_requests) for more details.

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/window/clearinterval/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ It's worth noting that the pool of IDs used by
{{domxref("Window.setInterval", "setInterval()")}} and
{{domxref("setTimeout()")}} are shared, which
means you can technically use `clearInterval()` and
{{domxref("Window.clearInterval", "clearInterval()")}} interchangeably.
{{domxref("clearTimeout()")}} interchangeably.
However, for clarity, you should avoid doing so.

### Return value
Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/window/setinterval/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ myArray.myMethod = function (sProperty) {
myArray.myMethod(); // prints "zero,one,two"
myArray.myMethod(1); // prints "one"
setTimeout(myArray.myMethod, 1000); // prints "[object Window]" after 1 second
setTimeout(myArray.myMethod, 1500, "1"); // prints "undefined" after 1,5 seconds
setTimeout(myArray.myMethod, 1500, "1"); // prints "undefined" after 1.5 seconds

// Passing the 'this' object with .call won't work
// because this will change the value of this inside setTimeout itself
Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/workerglobalscope/setinterval/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ setInterval(func, delay, arg1, arg2, /* …, */ argN)
This syntax is _not recommended_ for the same reasons that make using {{jsxref("Global_Objects/eval", "eval()")}} a security risk.
- `delay` {{optional_inline}}
- : The time, in milliseconds (thousandths of a second), the timer should delay in between executions of the specified function or code. Defaults to 0 if not specified.
See [Delay restrictions](#delay_restrictions) below for details on the permitted range of `delay` values.
See [Delay restrictions](/en-US/docs/Web/API/Window/setInterval#delay_restrictions) for details on the permitted range of `delay` values.
- `arg1`, …, `argN` {{optional_inline}}
- : Additional arguments which are passed through to the function specified by _func_ once the timer expires.

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/html/element/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Metadata contains information about the page. This includes information about st

| Element | Description |
| ----------------------- | --------------------------------------------------------------------------------------------- |
| {{HTMLElement("body")}} | represents the content of an HTML document. There can be only one such element in a document. |
| {{HTMLElement("body")}} | Represents the content of an HTML document. There can be only one such element in a document. |

## Content sectioning

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ new Promise(executor)

### Return value

When called via `new`, the `Promise` constructor returns a promise object. The promise object will become _resolved_ when either of the functions `resolveFunc` or `rejectFunc` are invoked. Note that if you call `resolveFunc` or `rejectFunc` and pass another `Promise` object as an argument, it can be said to be "resolved", but still not "settled". See the [Promise description](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise#description) for more explanation.
When called via `new`, the `Promise` constructor returns a promise object. The promise object will become _resolved_ when either of the functions `resolveFunc` or `rejectFunc` are invoked. Note that if you call `resolveFunc` and pass another promise object as an argument, the initial promise can be said to be "resolved", but still not "settled". See the [Promise description](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise#description) for more explanation.

## Description

Expand Down

0 comments on commit ef8af4a

Please sign in to comment.