Recent Qualtrics change broke JavaScript codes with remove() | XM Community
Skip to main content

Hello everyone,

 

I recently got a notification from some users of my Google Maps component that it no longer worked.

Some notes about the issue are here with my investigation, it seems that there is an issue in the Qualtrics-provided code that hangs with a certain logic.

 

In short, it seems the code overrides the behavior of ChildNode.remove(), yet lacks the validation of the parent node of an HTML element when it removes itself.

// prototype.45d699cfb71157c2bc5a.js:1:30423
function c(t) {
return (t = e(t)), t.parentNode.removeChild(t), t; // t.parentNode could be undefined
}

 

Therefore, the minimal code to replicate the issue below:

var x = document.createElement("div");
x.remove();
alert("Hello World!"); // does not work

stops at line 2 and does not show the alert.

 

It means that, sadly, any package or external JavaScript that removes HTML elements in their code will no longer work. In my case, Google Maps API tried to add a navigation tooltip and it caused an error.

// map.js:107:415
var x = document.createElement("span");
x.textContent =
"To navigate the map with touch gestures double-tap and hold your finger on the map, then drag the map.";
_.Ft(a, "gesturehandling_changed", () => {
_.qu() && "none" !== a.get("gestureHandling") ? w.prepend(x) : x.remove(); // remove() does not work
});

 

1 - Does anyone else experience this issue recently?

2 - If so, to Qualtrics, isn’t it really a problem to fix? 

The remove function removes and element from the DOM. Your code is throwing an error because it hasn’t been added to there.

If your line 2 inserts the element to the DOM, for example:

document.body.insertAdjacentElement("beforeend",x)

 

Then x.remove() will not throw an error. 


But indeed, for instance, the code from the Google Maps API doesn’t do so and it stops the execution on Qualtrics, so my point is that any external packages or codes that call the remove function without inserting itself will not work. Is that right?


Leave a Reply