Nir Yosef
Premium
Shlomi Toussia-Cohen
CX (Infra-team)
Guild Week #2
beforeEach(() => {
driver = new WixInputDriver();
});
it('should render the wix-input with an input element', () => {
driver
.given.attributes({type: 'email', 'ng-model': 'email'})
.when.created();
expect(driver.get.inputElement().length).toBe(1);
});
//Given directive:
<wix-input ng-click="sayHello()"/>
//Compiled to:
<wix-input> //**but ngClick was already compiled!**
...
<input ng-click="sayHello()"/>
...
</wix-input>
angular.module('wixStyleInternal')
.directive('wixInput', function (wixDirectivesUtils) {
return {
restrict: 'E',
priority: 550, //compile after ngIf, but before ngClick
terminal: true, //stop compilation
template: '<input/>',
compile: function (element, $attrs) {
const input = element.find('input');
wixDirectivesUtils.moveAttributesToChild(
element, input, $attrs, ['ngIf']
);
//... later will compile only the input
}
};
}
angular
.module('yourApp')
.config(function (wixStyleConfigProvider) {
wixStyleConfigProvider.useNewWixInput(true);
});