I have a custom component and when I try to use the following code:
Component.cmp
<aura:component implements='forceCommunity:availableForAllPageTypes' access='global'>
<aura:handler name="init" value="{!this}" action="{!c.executeComponentInitilization}"/>
</aura:component>
ComponentController.js
({
executeComponentInitilization : function(component, event, helper) {
var req = new XMLHttpRequest();
req.onreadystatechange = function(event) {
// XMLHttpRequest.HEADERS_RECEIVED
if (req.readyState == 2) {
req.responseType = "document";
// XMLHttpRequest.DONE
} else if (req.readyState == 4) {
if (req.status === 200) {
console.log(req.response);
debugger;
} else {
// Something went wrong.
debugger;
}
}
};
req.open('GET', 'https://anHTMLpage.com'); // used https://sitepreview.na40.force.com for tests
req.send(null);
}
})
When LockerService is off, I am able to get a nice and sweet Document
DOM object for the XMLHttpRequest.response
when the responseType
is document
, but when LockerService is enabled, I only get an Object
with a toString()
method that returns:
"SecureObject: [object HTMLDocument]{ key: {"namespace":"mynamepsace"} }"
Is this a bug? If so, will it be fixed in Summer 17? I tried to use the document.implementation.createHTMLDocument
but it creates a document
DOM without the right LockerService key/namespace.
document
objects is a non-trivial problem. If you need this behavior please bring it up through a more "official" SFDC channel like a customer case.