Closed aendra-rininsland closed 8 years ago
Additionally, could also throw a warning if an underscore-prefixed property is defined in properties
to enforce the convention.
The underscore is enough to delineate the intended level of privacy, there's no reason to leave the property out of the properties
block. e.g. https://github.com/PolymerElements/paper-input/blob/master/paper-input-behavior.html#L354 - the privacy is also respected in the docs, e.g. https://elements.polymer-project.org/elements/paper-input
There's good reasons to do initialization inside of properties
, as it allows the data binding system to handle initialization, which can mean fewer data binding round trips, as well as less surprising behavior when a default value conflicts with an explicitly set value.
@rictic Cool, thanks for the explanation! Have always been a bit confused by that in particular. Guess I'll start populating properties
more than I have? :sweat_smile:
I frequently use "private" methods/properties (I put in quote marks because I mentioned this in the Polymer Slack and it started a half hour-long discussion about what "private" really means in JS...) that aren't defined in
properties
, but are instead defined in theready
lifecycle method. From what I can tell, this is a fairly accepted practice, as is prefixing such properties/methods with underscores.Alas, Polylint still throws the
Property x not found in 'properties' for an-element
warning because I haven't declared them inproperties
. Is there any way an exception could be written for properties prefixed with_
?Thanks!