aurelia / validatejs

Enables expressive validation using decorators and/or a fluent API.
MIT License
22 stars 23 forks source link

enable using validate decorator in custom attribute binding #97

Closed JeroenVinke closed 8 years ago

JeroenVinke commented 8 years ago

When putting the validate binding behavior on a custom attribute's bindable variable the following error is thrown:

VM568 aurelia.js:20531 Uncaught (in promise) TypeError: Cannot read property 'firstChild' of null
    at ValidateBindingBehavior.getTarget (https://jdanyow.github.io/rjs-bundle/bundles/aurelia.js:20531:29)
    at ValidateBindingBehavior.bind (https://jdanyow.github.io/rjs-bundle/bundles/aurelia.js:20537:25)
    at BindingBehavior.bind (https://jdanyow.github.io/rjs-bundle/bundles/aurelia.js:1880:21)
    at Binding.bind (https://jdanyow.github.io/rjs-bundle/bundles/aurelia.js:5378:31)
    at Controller.bind (https://jdanyow.github.io/rjs-bundle/bundles/aurelia.js:11864:19)
    at View.bind (https://jdanyow.github.io/rjs-bundle/bundles/aurelia.js:9955:24)
    at Controller.bind (https://jdanyow.github.io/rjs-bundle/bundles/aurelia.js:11886:19)
    at View.bind (https://jdanyow.github.io/rjs-bundle/bundles/aurelia.js:9955:24)
    at Controller.bind (https://jdanyow.github.io/rjs-bundle/bundles/aurelia.js:11886:19)
    at Controller.automate (https://jdanyow.github.io/rjs-bundle/bundles/aurelia.js:11831:12)

https://gist.run/?id=14ac85668b3ca27dcd8ad6d3f6579fb0/7bae372b9b6f18353f9faba700cef18581884210

JeroenVinke commented 8 years ago

I can create a PR with some tests for this, but i'm having a hard time getting to the element on which the custom attribute has been placed. I have access to the Controller behind the custom attribute, but the element where the attribute has been placed on isn't there as far as I can see. The create function of the HtmlBehaviorResource has both the element and the Controller but it does not push the element onto the controller (not when it's a custom attribute that's being created).

Is there a different way to get to the element, or should we push the element on the controller in the HtmlBehaviorResource's create function?

jdanyow commented 8 years ago

Issue moved to aurelia/validation #288 via ZenHub