Ticket #276 (closed enhancement: fixed)
Problem with Selector
| Reported by: | sschz@… | Owned by: | cederberg@… |
|---|---|---|---|
| Priority: | normal | Milestone: | MochiKit 1.4 |
| Component: | component1 | Version: | |
| Severity: | normal | Keywords: | |
| Cc: |
Description
There is a problem when using the Selector object.
Description
Something like:
var selector = new MochiKit.Selector.Selector('script[src="srcValue"]');
var matches = selector.findElements(document.getElementsByTagName('head')[0]);
would work properly even if there are some script elements with no src attribute.
On the contrary, if doing:
var selector = new MochiKit.Selector.Selector('script[src$="srcValue"]');
var matches = selector.findElements(document.getElementsByTagName('head')[0]);
and there are some script elements with no src attribute, this would throw an error.
Proposed solution
It would be nice if, instead of doing
conditions.push(value + '.substring(' + value + '.length - ' + attribute.value.length + ') == ' + repr(attribute.value));
at the Selector buildMatchExpression function, the existence of the property were taken into account or, if not, the selector 'script[src][src$="srcValue"]' were performed as a shortcut.
Change History
Note: See
TracTickets for help on using
tickets.
