Bug 1613155 - Set dir property on the HTML element instead of <root>. r=andreio

Differential Revision: https://phabricator.services.mozilla.com/D61591

--HG--
extra : moz-landing-system : lando
This commit is contained in:
emcminn 2020-02-04 17:37:43 +00:00
parent f4ac3e0dc0
commit 45bea3317f
3 changed files with 5 additions and 4 deletions

View File

@ -304,7 +304,7 @@ export class ASRouterUISurface extends React.PureComponent {
}
if (endpoint && endpoint.dir === "rtl") {
//Set `dir = rtl` on the HTML
this.props.document.getElementById("root").dir = "rtl";
this.props.document.dir = "rtl";
}
ASRouterUtils.addListener(this.onMessageFromParent);
this.requestMessage(endpoint);

View File

@ -2367,7 +2367,7 @@ class ASRouterUISurface extends react__WEBPACK_IMPORTED_MODULE_6___default.a.Pur
if (endpoint && endpoint.dir === "rtl") {
//Set `dir = rtl` on the HTML
this.props.document.getElementById("root").dir = "rtl";
this.props.document.dir = "rtl";
}
ASRouterUtils.addListener(this.onMessageFromParent);

View File

@ -204,11 +204,12 @@ describe("ASRouterUISurface", () => {
assert.property(stub.firstCall.args[0].detail.data, "sidebar_text");
});
it("should set `dir=rtl` on the page's root element if the dir param is set", () => {
it("should set `dir=rtl` on the page's <html> element if the dir param is set", () => {
assert.notPropertyVal(fakeDocument, "dir", "rtl");
sandbox.stub(ASRouterUtils, "getPreviewEndpoint").returns({ dir: "rtl" });
wrapper = mount(<ASRouterUISurface document={fakeDocument} />);
assert.propertyVal(root, "dir", "rtl");
assert.propertyVal(fakeDocument, "dir", "rtl");
});
describe("snippets", () => {