I had a Windows 8.1 jsproject, now updated to the Universal Windows (UAP/UWP)app.
Previously this function was working, it was calling like
installLocationProxy(window);
installLocationProxy(document);
function installLocationProxy(obj) {
var descriptor;
var descriptorProto = obj;
do {
descriptor = Object.getOwnPropertyDescriptor(descriptorProto, "location");
descriptorProto = !descriptor && descriptorProto && Object.getPrototypeOf(descriptorProto);
} while (descriptor == null);
if (!descriptor || !descriptor.get || !descriptor.set)
return;
var proxy = new LocationProxy(descriptor.get.call(obj));
Object.defineProperty(obj, "location", {
"get": function () {
return proxy;
},
"set": function (location) {
if (typeof location === 'string' || location && location instanceof String) {
proxy.assign(location, NavigationMethods.Location);
}
else {
return descriptor.set.call(obj, location);
}
}
});
}
but now I am getting error "Cannot redefine non-configurable property 'location'" on this line Object.defineProperty(obj, "location"
.
While googling I found that the now the window.location is readonly and not writable, so it cannot be overridden.
For reference, it can be checked here
https://gist.github.com/zacharytamas/082e538784ebe07e40f9
But I am not sure how to override the window.location
property? Can anybody help?