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

Prevent extractValue from blowing up on undefined #477

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

Prevent extractValue from blowing up on undefined #477

wants to merge 1 commit into from

Commits on Mar 11, 2017

  1. Prevent extractValue from blowing up on undefined

    Given that angucomplete-alt supports passing a `.` separated key in `image-field` (and other fields), this fix will prevent an error in the case of an undefined value.
    
    That is, given:
    ```
    let data = [{
        // ...
        id: 1,
        logo: undefined,
        // ...
    } , {
        // ...
        id: 2,
        logo: {
            thumbnail: '/img/users/portrait.png'}
        }
    }]
    ```
    and passing `image-field="logo.thumbnail" local-data="data"` to angucomplete-alt, this currently causes an error on the first item: `TypeError: Cannot read property 'thumbnail' of undefined`, and no further items are rendered in the autocomplete dropdown.
    
    This PR just adds a check to see if the current value exists before attempting to access the property.
    
    Came across this in the course of work, just thought I'd submit this fix for you (worked around it locally). Let me know if you need me to do more to improve the PR, but it seems fairly trivial.
    
    Regards, 
    Callum
    clov3r authored Mar 11, 2017
    Configuration menu
    Copy the full SHA
    ab2719a View commit details
    Browse the repository at this point in the history