Skip to content
This repository has been archived by the owner on Oct 2, 2019. It is now read-only.

Commit

Permalink
chore: normalize line endings
Browse files Browse the repository at this point in the history
- This adds the necessary files (.gitattributes and .editorconfig) to ensure line endings use lf
  • Loading branch information
wesleycho committed Mar 31, 2016
1 parent 2647e0f commit 6dfe407
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 58 deletions.
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org

root = true

[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

# Tabs in JS unless otherwise specified
[**.js]
indent_style = space
indent_size = 2

[*.md]
trim_trailing_whitespace = false
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*.html eol=lf
*.css eol=lf
*.js eol=lf
*.md eol=lf
*.json eol=lf
*.yml eol=lf
18 changes: 9 additions & 9 deletions dist/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -2038,15 +2038,15 @@ uis.service('uisRepeatParser', ['uiSelectMinErr','$parse', function(uiSelectMinE
// When using (key,value) ui-select requires filters to be extracted, since the object
// is converted to an array for $select.items
// (in which case the filters need to be reapplied)
if (match[3]) {
// Remove any enclosing parenthesis
source = match[5].replace(/(^\()|(\)$)/g, '');
// match all after | but not after ||
var filterMatch = match[5].match(/^\s*(?:[\s\S]+?)(?:[^\|]|\|\|)+([\s\S]*)\s*$/);
if(filterMatch && filterMatch[1].trim()) {
filters = filterMatch[1];
source = source.replace(filters, '');
}
if (match[3]) {
// Remove any enclosing parenthesis
source = match[5].replace(/(^\()|(\)$)/g, '');
// match all after | but not after ||
var filterMatch = match[5].match(/^\s*(?:[\s\S]+?)(?:[^\|]|\|\|)+([\s\S]*)\s*$/);
if(filterMatch && filterMatch[1].trim()) {
filters = filterMatch[1];
source = source.replace(filters, '');
}
}

return {
Expand Down
18 changes: 9 additions & 9 deletions src/uiSelectMatchDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ uis.directive('uiSelectMatch', ['uiSelectConfig', function(uiSelectConfig) {
}
};

function getAttribute(elem, attribute) {
if (elem[0].hasAttribute(attribute))
return elem.attr(attribute);

if (elem[0].hasAttribute('data-' + attribute))
return elem.attr('data-' + attribute);

if (elem[0].hasAttribute('x-' + attribute))
return elem.attr('x-' + attribute);
function getAttribute(elem, attribute) {
if (elem[0].hasAttribute(attribute))
return elem.attr(attribute);

if (elem[0].hasAttribute('data-' + attribute))
return elem.attr('data-' + attribute);

if (elem[0].hasAttribute('x-' + attribute))
return elem.attr('x-' + attribute);
}
}]);
18 changes: 9 additions & 9 deletions src/uisRepeatParserService.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ uis.service('uisRepeatParser', ['uiSelectMinErr','$parse', function(uiSelectMinE
// When using (key,value) ui-select requires filters to be extracted, since the object
// is converted to an array for $select.items
// (in which case the filters need to be reapplied)
if (match[3]) {
// Remove any enclosing parenthesis
source = match[5].replace(/(^\()|(\)$)/g, '');
// match all after | but not after ||
var filterMatch = match[5].match(/^\s*(?:[\s\S]+?)(?:[^\|]|\|\|)+([\s\S]*)\s*$/);
if(filterMatch && filterMatch[1].trim()) {
filters = filterMatch[1];
source = source.replace(filters, '');
}
if (match[3]) {
// Remove any enclosing parenthesis
source = match[5].replace(/(^\()|(\)$)/g, '');
// match all after | but not after ||
var filterMatch = match[5].match(/^\s*(?:[\s\S]+?)(?:[^\|]|\|\|)+([\s\S]*)\s*$/);
if(filterMatch && filterMatch[1].trim()) {
filters = filterMatch[1];
source = source.replace(filters, '');
}
}

return {
Expand Down
62 changes: 31 additions & 31 deletions test/select.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,21 +412,21 @@ describe('ui-select tests', function() {
expect(getMatchLabel(el)).toEqual('Samantha');
});

it('should correctly render initial state with track by $index', function () {

var el = compileTemplate(
'<ui-select ng-model="selection.selected"> \
<ui-select-match placeholder="Pick one...">{{$select.selected.name}}</ui-select-match> \
<ui-select-choices repeat="person in people track by $index"> \
{{person.email}} \
</ui-select-choices> \
</ui-select>'
);

openDropdown(el);

var generatedId = el.scope().$select.generatedId;
expect($(el).find('[id="ui-select-choices-row-' + generatedId + '-0"]').length).toEqual(1);
it('should correctly render initial state with track by $index', function () {

var el = compileTemplate(
'<ui-select ng-model="selection.selected"> \
<ui-select-match placeholder="Pick one...">{{$select.selected.name}}</ui-select-match> \
<ui-select-choices repeat="person in people track by $index"> \
{{person.email}} \
</ui-select-choices> \
</ui-select>'
);

openDropdown(el);

var generatedId = el.scope().$select.generatedId;
expect($(el).find('[id="ui-select-choices-row-' + generatedId + '-0"]').length).toEqual(1);
});

it('should utilize wrapper directive ng-model', function() {
Expand Down Expand Up @@ -1607,42 +1607,42 @@ describe('ui-select tests', function() {
expect(el.find('.ui-select-match-item').length).toBe(0);
});

it('should render intial state with data-multiple attribute', function () {
// ensure match template has been loaded by having more than one selection
scope.selection.selectedMultiple = [scope.people[0], scope.people[1]];

it('should render intial state with data-multiple attribute', function () {
// ensure match template has been loaded by having more than one selection
scope.selection.selectedMultiple = [scope.people[0], scope.people[1]];

var el = compileTemplate(
'<ui-select data-multiple ng-model="selection.selectedMultiple" theme="bootstrap" style="width: 800px;"> \
<ui-select-match placeholder="Pick one...">{{$item.name}} &lt;{{$item.email}}&gt;</ui-select-match> \
<ui-select-choices repeat="person in people | filter: $select.search"> \
<div ng-bind-html="person.name | highlight: $select.search"></div> \
<div ng-bind-html="person.email | highlight: $select.search"></div> \
</ui-select-choices> \
</ui-select>'
);

</ui-select>'
);

expect(el).toHaveClass('ui-select-multiple');
expect(el.scope().$select.selected.length).toBe(2);
expect(el.find('.ui-select-match-item').length).toBe(2);
expect(el.find('.ui-select-match-item').length).toBe(2);
});

it('should render intial state with x-multiple attribute', function () {
// ensure match template has been loaded by having more than one selection
scope.selection.selectedMultiple = [scope.people[0], scope.people[1]];

it('should render intial state with x-multiple attribute', function () {
// ensure match template has been loaded by having more than one selection
scope.selection.selectedMultiple = [scope.people[0], scope.people[1]];

var el = compileTemplate(
'<ui-select x-multiple ng-model="selection.selectedMultiple" theme="bootstrap" style="width: 800px;"> \
<ui-select-match placeholder="Pick one...">{{$item.name}} &lt;{{$item.email}}&gt;</ui-select-match> \
<ui-select-choices repeat="person in people | filter: $select.search"> \
<div ng-bind-html="person.name | highlight: $select.search"></div> \
<div ng-bind-html="person.email | highlight: $select.search"></div> \
</ui-select-choices> \
</ui-select>'
);

</ui-select>'
);

expect(el).toHaveClass('ui-select-multiple');
expect(el.scope().$select.selected.length).toBe(2);
expect(el.find('.ui-select-match-item').length).toBe(2);
expect(el.find('.ui-select-match-item').length).toBe(2);
});

it('should set model as an empty array if ngModel isnt defined after an item is selected', function () {
Expand Down

0 comments on commit 6dfe407

Please sign in to comment.