These two methods always work if the app just uses JQLite, which can only select elements by tagName. However, if an app uses full Jquery, a selector may return no elements with no associated tagName (i.e. angular.element('.class-selector-with-no-matched-elements') ), at which point these methods throw a JS error. This just inserts a check to see if the element even exists at all, and returns false if not.
This actually came up in our app which does use JQuery and prevented the loading of another JQuery library.
These two methods always work if the app just uses JQLite, which can only select elements by tagName. However, if an app uses full Jquery, a selector may return no elements with no associated tagName (i.e. angular.element('.class-selector-with-no-matched-elements') ), at which point these methods throw a JS error. This just inserts a check to see if the element even exists at all, and returns false if not.
This actually came up in our app which does use JQuery and prevented the loading of another JQuery library.