Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "Cannot read property 'leaves' of undefined" #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hex0id
Copy link
Contributor

@hex0id hex0id commented Dec 30, 2015

And template restructure

@markguinn
Copy link
Owner

Can you tell me a little more about what this is fixing? What were the circumstances that triggered this?

@hex0id
Copy link
Contributor Author

hex0id commented Dec 30, 2015

if I use checkbox facet, there is this script "/shop_search/javascript/search.facets.checkbox.js". on lines 61 and 62 there are some variables:

            // construct the new url
            var url  = $label.data('url'),
                info = $root.data('link-details'),
                sel  = info.leaves ? 'label:not([data-children]) > input[type=checkbox]' : 'input[type=checkbox]',
                key  = '&' + encodeURIComponent(info.filter + '[' + info.source + ']') + '=LIST~',
                ids  = [];

and here's a part of template:

<% if $NestedValues %>
    <ul data-root data-hierarchy="true" data-link-details="$ATT_val('LinkDetails')">
        <% loop $NestedValues %>
            <% include FacetTypeCheckboxInner %>
        <% end_loop %>
    </ul>
<% else %>
    <ul data-root>
        <% loop $Values %>
            <% include FacetTypeCheckboxInner %>
        <% end_loop %>
    </ul>
<% end_if %>

Problem - if there are no $NestedValues then data-link-details is empty, then "info" is empty hence info.leaves is undefined.

@hex0id
Copy link
Contributor Author

hex0id commented Jan 6, 2016

@markguinn does my explanation give you any idea of what I am trying to fix?

@markguinn
Copy link
Owner

It does. I'll try to get back to this at the weekend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants