Please see jQuery source code: https://code.jquery.com/jquery-2.1.3.js
If we search for text "<iframe" then we can see below function:
function defaultDisplay( nodeName ) {
var doc = document,
display = elemdisplay[ nodeName ];
if ( !display ) {
display = actualDisplay( nodeName, doc );
// If the simple way fails, read from inside an iframe
if ( display === "none" || !display ) {
// Use the already-created iframe if possible
iframe = (iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" )).appendTo( doc.documentElement );
// Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
doc = iframe[ 0 ].contentDocument;
// Support: IE
doc.write();
doc.close();
display = actualDisplay( nodeName, doc );
iframe.detach();
}
// Store the correct default display
elemdisplay[ nodeName ] = display;
}
return display;
}
This works fine, however, our Web firewall blocks this file because of suspecting possible iframe injection. It seems the function is creating iframe element and appends the element. Later, it uses the iframe to get the display value.
Any workaround/alternatives of using iframe so that we can replace the line which reads:
iframe = (iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" )).appendTo( doc.documentElement );
Kindly note that I cannot change the firewall provider. Further, this is on AngularJS 1.4.5, does it have any dependencies on jQuery version? All I know is that AngularJS 1.4.5 requires jQuery, but not sure which version.
Has anybody used AngularJS 1.4.5 with latest jQuery version?
2
Answers
Here is what I ended up with:
This way, now the proxy server isn't showing any error message as text "<iframe" is not found and we are creating by other means of JS.
If you check the Angular JS FAQ, there’s a question about the use of jQuery in Angular JS 1.4.5 (emphasis is mine)
As you can see from this, there is no hard dependency upon jQuery at all and Angular JS will use it’s own version of jQuery, jQLite.
You should be okay to completely remove jQuery from your Angular JS page(s) assuming it’s not being used anywhere else.
Unfortunately it’s not clear whether the "supports jQuery 2.1 or above" includes major versions.