domNode.isConnected
is a flag which is available in chrome. It shows whether domNode is part of the document.
Is it cross browser compatible?
If not is there any efficient alternative for this for other browsers?
Please provide link for any available documentation.
It is not supported, but very easy to polyfill.
(function (supported){
if (supported) return;
Object.defineProperty(window.Node.prototype, 'isConnected', {get})
function get() {
return document.contains(this);
}
})('isConnected' in window.Node.prototype);
A quick test shows Firefox doesn't support this property. So the answer is no.
var input = document.getElementById('input');
alert(input.isConnected);
<input type="text" id="input">
https://jsfiddle.net/hu08awn0/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With