Skip to content

Commit

Permalink
feat(api): disable attribute by passing null
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat committed Oct 7, 2019
1 parent 22eb531 commit 3ac02f3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as d from '../../../declarations';
import { augmentDiagnosticWithNode, buildError, catchError, toDashCase } from '@utils';
import { augmentDiagnosticWithNode, buildError, buildWarn, catchError, toDashCase } from '@utils';
import { convertValueToLiteral, createStaticGetter, getAttributeTypeInfo, isMemberPrivate, resolveType, serializeSymbol, typeToString, validateReferences } from '../transform-utils';
import { isDecoratorNamed } from './decorator-utils';
import { validatePublicName } from '../reserved-public-members';
Expand Down Expand Up @@ -94,7 +94,11 @@ const parsePropDecorator = (config: d.Config, diagnostics: d.Diagnostic[], typeC
return staticProp;
};

const getAttributeName = (_diagnostics: d.Diagnostic[], propName: string, propOptions: d.PropOptions) => {
const getAttributeName = (diagnostics: d.Diagnostic[], propName: string, propOptions: d.PropOptions) => {
if (propOptions.attribute === null) {
return undefined;
}

if (typeof propOptions.attribute === 'string' && propOptions.attribute.trim().length > 0) {
return propOptions.attribute.trim().toLowerCase();
}
Expand Down
2 changes: 1 addition & 1 deletion src/declarations/decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export interface PropOptions {
* Stencil uses different heuristics to determine the default name of the attribute,
* but using this property, you can override the default behaviour.
*/
attribute?: string;
attribute?: string | null;

/**
* A Prop is _by default_ immutable from inside the component logic.
Expand Down

0 comments on commit 3ac02f3

Please sign in to comment.