(In reply to Jonathan Kew [:jfkthame] from comment #17) > (In reply to Hamish Willee from comment #15) >... > If created directly using the `OffscreenCanvas` constructor, yes. But if it is created from a canvas element using the [`transferControlToOffscreen`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/transferControlToOffscreen) method, I believe it'll inherit its lang from that element (rather than from the document); see also [the HTML spec](https://html.spec.whatwg.org/multipage/canvas.html#dom-canvas-transfercontroltooffscreen). Thanks @Jonathan. I think you're right that the `lang` will come from the element for that method IF the element has a `lang`, and will otherwise inherit from the parent element and so on. But if you look at the [first example you point to](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/transferControlToOffscreen#examples) the `htmlCanvas` doesn't have a parent element and hence no `lang` (I think it defaults to null.) ```js const htmlCanvas = document.createElement("canvas"); const offscreen = htmlCanvas.transferControlToOffscreen(); ``` Above I said this would mean that the offscreen canvas got the `lang` of the root, but that doesn't make sense. I think it will remain null in this case unless explicitly assigned. Does that make sense?
Bug 1943070 Comment 18 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
(In reply to Jonathan Kew [:jfkthame] from comment #17) > (In reply to Hamish Willee from comment #15) >... > If created directly using the `OffscreenCanvas` constructor, yes. But if it is created from a canvas element using the [`transferControlToOffscreen`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/transferControlToOffscreen) method, I believe it'll inherit its lang from that element (rather than from the document); see also [the HTML spec](https://html.spec.whatwg.org/multipage/canvas.html#dom-canvas-transfercontroltooffscreen). Thanks @Jonathan. I think you're right that the `lang` will come from the element for that method IF the element has a `lang`, and will otherwise inherit from the parent element and so on. But if you look at the [first example you point to](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/transferControlToOffscreen#examples) the `htmlCanvas` doesn't have a parent element and hence no `lang` (I think it defaults to null.) ```js const htmlCanvas = document.createElement("canvas"); const offscreen = htmlCanvas.transferControlToOffscreen(); ``` Above I said this would mean that the offscreen canvas got the `lang` of the root. If this is true, it means that there is some "magic" to get this from the document root - since the element in this case is never part of the DOM tree. Does that make sense?
(In reply to Jonathan Kew [:jfkthame] from comment #17) > (In reply to Hamish Willee from comment #15) >... > If created directly using the `OffscreenCanvas` constructor, yes. But if it is created from a canvas element using the [`transferControlToOffscreen`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/transferControlToOffscreen) method, I believe it'll inherit its lang from that element (rather than from the document); see also [the HTML spec](https://html.spec.whatwg.org/multipage/canvas.html#dom-canvas-transfercontroltooffscreen). Thanks @Jonathan. I think you're right that the `lang` will come from the element for that method IF the element has a `lang`, and will otherwise inherit from the parent element and so on. But if you look at the [first example you point to](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/transferControlToOffscreen#examples) the `htmlCanvas` doesn't have a parent element and hence no `lang` (I think it defaults to null.) ```js const htmlCanvas = document.createElement("canvas"); const offscreen = htmlCanvas.transferControlToOffscreen(); ``` Above I said this would mean that the offscreen canvas got the `lang` of the root. If this is true, it means that there is some "magic" to get this from the document root - since the element in this case is never part of the DOM tree. Can you confirm that in the above case the `offscreen` lang would be that of the Document, and not `null?` Does that make sense?
(In reply to Jonathan Kew [:jfkthame] from comment #17) > (In reply to Hamish Willee from comment #15) >... > If created directly using the `OffscreenCanvas` constructor, yes. But if it is created from a canvas element using the [`transferControlToOffscreen`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/transferControlToOffscreen) method, I believe it'll inherit its lang from that element (rather than from the document); see also [the HTML spec](https://html.spec.whatwg.org/multipage/canvas.html#dom-canvas-transfercontroltooffscreen). Thanks @Jonathan. I think you're right that the `lang` will come from the element for that method IF the element has a `lang`, and will otherwise inherit from the parent element and so on. But if you look at the [first example you point to](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/transferControlToOffscreen#examples) the `htmlCanvas` doesn't have a parent element and hence no `lang` (I think it defaults to null.) ```js const htmlCanvas = document.createElement("canvas"); const offscreen = htmlCanvas.transferControlToOffscreen(); ``` Above I said this would mean that the offscreen canvas got the `lang` of the root. If this is true, it means that there is some "magic" to get this from the document root - since the element in this case is never part of the DOM tree. Can you confirm that in the above case the `offscreen` lang would be that of the Document, and not `null?` Anyway, I made a minor tidy to this in https://github.com/mdn/content/pull/44071/changes
(In reply to Jonathan Kew [:jfkthame] from comment #17) > (In reply to Hamish Willee from comment #15) >... > If created directly using the `OffscreenCanvas` constructor, yes. But if it is created from a canvas element using the [`transferControlToOffscreen`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/transferControlToOffscreen) method, I believe it'll inherit its lang from that element (rather than from the document); see also [the HTML spec](https://html.spec.whatwg.org/multipage/canvas.html#dom-canvas-transfercontroltooffscreen). Thanks @Jonathan. I think you're right that the `lang` will come from the element for that method IF the element has a `lang`, and will otherwise inherit from the parent element and so on. But if you look at the [first example you point to](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/transferControlToOffscreen#examples) the `htmlCanvas` doesn't have a parent element and hence no `lang` (I think it defaults to null.) ```js const htmlCanvas = document.createElement("canvas"); const offscreen = htmlCanvas.transferControlToOffscreen(); ``` Above I said this would mean that the offscreen canvas got the `lang` of the root. If this is true, it means that there is some "magic" to get this from the document root - since the element in this case is never part of the DOM tree. Anyway, I made a minor tidy to this in https://github.com/mdn/content/pull/44071/changes