Skip to content

Commit

Permalink
Fix selector priority in apply method
Browse files Browse the repository at this point in the history
The array sort function was used incorrectly, but happened to behave as
expected in the scenario given by the unit tests.

Change-Id: I789875044b294002f248ceb8ecfa116de8f444a0
  • Loading branch information
tbuschto committed May 15, 2018
1 parent 469e34b commit e0bbed6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/tabris/Widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export default class Widget extends NativeObject {
}
Object.keys(sheet)
.map(key => [createSelectorArray(key, this), sheet[key]])
.sort(rule => getSelectorSpecificity(rule[0]))
.sort((rule1, rule2) => getSelectorSpecificity(rule1[0]) - getSelectorSpecificity(rule2[0]))
.forEach(rule => {
scope.filter(rule[0]).set(rule[1]);
});
Expand Down
2 changes: 1 addition & 1 deletion test/tabris/Widget.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1055,10 +1055,10 @@ describe('Widget', function() {

it('applies properties in order *, Type, (pseudo-)class, id', function() {
widget.apply({
'TestWidget': {prop1: 'v2'},
'#foo': {prop1: 'v4'},
'.myclass': {prop1: 'v3'},
':host': {prop1: 'v3'},
'TestWidget': {prop1: 'v2'},
'*': {prop1: 'v1'}
});

Expand Down

0 comments on commit e0bbed6

Please sign in to comment.