Paweł
Paweł

Reputation: 148

UI Bootstrap - missing contains implementation

How is it possible that jqLite doesn't provide the method "contains" on element (docs), angular bootstrap doesn't provide it neither (source), angular bootstrap doesn't depend on jQuery (package.json), nevertheless angular bootstrap is using it (line 2943)? Where does it come from?

Upvotes: 3

Views: 54

Answers (1)

mortb
mortb

Reputation: 9849

I'll try to explain:

$element is a HTMLElement browser html object which is wrapped in a JQuery/JQlite object.

When you call $element[0] you get first the actual HTMLElement that is wrapped (in this case the authors know that only one element is wrapped).

HTMLElement inherits from Node. The Node object has the contains(...) method.

Reference:

HTMLElement: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement

Node: https://developer.mozilla.org/en-US/docs/Web/API/Node

Upvotes: 2

Related Questions