Skip to content

element.parent not a function for empty item #255

@asmund1

Description

@asmund1

If I have the translate keyword on an empty item (in this case a div)

    <div translate>

    </div>

I get the following error:

TypeError: element.parent is not a function
    at queueAnimation (http://localhost:8100/lib/ionic/js/ionic.bundle.js:43785:26)
    at Object.push (http://localhost:8100/lib/ionic/js/ionic.bundle.js:43737:16)
    at Object.enter (http://localhost:8100/lib/ionic/js/ionic.bundle.js:18494:31)
    at update (http://localhost:8100/lib/angular-gettext/dist/angular-gettext.js:223:34)
    at post (http://localhost:8100/lib/angular-gettext/dist/angular-gettext.js:233:21)
    at invokeLinkFn (http://localhost:8100/lib/ionic/js/ionic.bundle.js:21963:9)
    at nodeLinkFn (http://localhost:8100/lib/ionic/js/ionic.bundle.js:21463:11)
    at compositeLinkFn (http://localhost:8100/lib/ionic/js/ionic.bundle.js:20854:13)
    at compositeLinkFn (http://localhost:8100/lib/ionic/js/ionic.bundle.js:20858:13)
    at nodeLinkFn (http://localhost:8100/lib/ionic/js/ionic.bundle.js:21458:24) <div translate="">

Seems like the contents() function on angular-gettext.js:221

var newContents = newWrapper.contents();

strips away the span of the element created on angular-gettext.js:219 if the span is empty (the translation is empty).

One (not very elegant) workaround is to add a space when creating the span element, which is then treated as not empty:

var newWrapper = angular.element('<span> ' + translated + '</span>');

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions