Skip to content

Commit

Permalink
Merge pull request #7 from Zefling/master
Browse files Browse the repository at this point in the history
Fix problem with data on init and less compilation
  • Loading branch information
plantain-00 authored Aug 7, 2017
2 parents ca76b02 + c9bd7a4 commit 3b23005
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion clean-scripts.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
`file2variable-cli src/angular.template.html -o src/angular-variables.ts --html-minify --base src`,
`ngc -p src`,
`tsc -p demo`,
`lessc src/select2.less > dist/select2.css`,
`lessc src/select2.less -sm=on > dist/select2.css`,
`cleancss -o dist/select2.min.css dist/select2.css`,
`cleancss -o demo/index.bundle.css dist/select2.min.css ./node_modules/github-fork-ribbon-css/gh-fork-ribbon.css`,
`webpack --display-modules --config demo/webpack.config.js`,
Expand Down
11 changes: 6 additions & 5 deletions src/angular.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -424,10 +424,11 @@ export class Select2 implements ControlValueAccessor {
this.option = null;
}

const value = this.option ? (this.multiple
const value = this.option
? (this.multiple
? (this.option as common.Select2Option[]).map(op => op.value)
: (this.option as common.Select2Option).value
) : undefined;
: (this.option as common.Select2Option).value)
: undefined;

if (this._control) {

Expand Down Expand Up @@ -547,12 +548,12 @@ export class Select2 implements ControlValueAccessor {
* found with the designated value, the select trigger is cleared.
*/
private _setSelectionByValue(value: any | any[]): void {
if ( this.option || value ) {
if (this.option || value) {
const isArray = Array.isArray(value);
if (this.multiple && value && !isArray) {
throw new Error("Non array value.");
} else {
const option = common.getOptionByValue(this.data, value);
const option = this.data ? common.getOptionByValue(this.data, value) : null;
this.select(option);
}

Expand Down
2 changes: 1 addition & 1 deletion src/select2.less
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ select2.material {
}

.select2-results__option[aria-selected=true],
.select2-results__option--highlighted[aria-selected] {
.select2-results__option--highlighted[aria-selected] {
background-color: rgba(0, 0, 0, 0.04);
color: #000;
}
Expand Down

0 comments on commit 3b23005

Please sign in to comment.