Skip to content Skip to sidebar Skip to footer

How To Make Cloned Dom Element Json Serializable

I'm currently working with GitHub's Electron framework, and I'm trying to send a cloned DOM element from a preloaded script in a webview through their IPC messaging system to my re

Solution 1:

If the IPC only takes string arguments, then you should send the HTML instead, which means, use

ipc.sendToHost("retrieve", cloned.outerHTML);

and then this

var html = e.args[0],
    dummy = document.createElement('div'),
    cloned;
dummy.innerHTML = html;
// this will give you the node that you sent with all the inline CSS
cloned = dummy.childNodes[0];

console.log(cloned );

Note: We can only pass inline styling, the CSS loaded at the document level cannot be serialized with html

Post a Comment for "How To Make Cloned Dom Element Json Serializable"