Skip to content

Commit

Permalink
fix(compiler): Allow data to be a valid prop name (#7)
Browse files Browse the repository at this point in the history
* Allowing data to be a valid propname

* using length instead of string equality check
  • Loading branch information
davidturissini authored Jan 17, 2018
1 parent ef42218 commit b5a7efd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,19 @@ describe('Public Props', () => {
}
});

test('does not throw error if property name is "data"', `
export default class Test {
@api data;
}
`, `
export default class Test {}
Test.publicProps = {
data: {
config: 0
}
};
`);

test('throws error if property name prefixed with "data"', `
export default class Test {
@api dataFooBar;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function validatePropertyName(property) {
throw property.buildCodeFrameError(
`Invalid property name ${propertyName}. Properties starting with "on" are reserved for event handlers.`
);
} else if (propertyName.startsWith('data')) {
} else if (propertyName.startsWith('data') && propertyName.length > 4) {
throw property.buildCodeFrameError(
`Invalid property name ${propertyName}. Properties starting with "data" are reserved attributes.`
);
Expand Down

0 comments on commit b5a7efd

Please sign in to comment.