Skip to content

Tips & Tricks

nhefner12 edited this page Sep 10, 2019 · 5 revisions

This where contributors can add tips and tricks for getting started and working with the project.

Property & Function Scope

While there's no scope enforcement for Javascript or Web Components, Polymer does have a scope convention we try to follow for this project. For names of properties or functions which should only be used internally by the class or web component HTML we prefix them with __ (2 underscores). For properties or functions which should only be used internally or by child classes we prefix them with _ (1 underscore). For Polymer web components this means functions and properties prefixed with _ can be used in some cases, but ones prefixed with __ should never be used because there's no guarantee they won't change in the future.

Behavior (base) Classes

(can't find property/function/observer)

Web components use classes, including base classes. Using Polymer requires extending Polymer.Element, but classes can also extend a behavior class which extends Polymer.Element. These behavior classes can define properties, functions, and observers which are inherited by the child class.

Polymer Element Content Slots

(fix for elements not showing up)

Some Polymer components, like app-header-layout, add custom handling of content elements using the slot parameter. If you don't set the slot parameter to a valid value the element may not be placed correctly or even visible.

Non-property Variables

(can't find property used in HTML)

We try to avoid it, but in some cases we may you variables in template HTML code which is not tied to an element property. These can be used to pass data from one element (ex. <some-component some-property="{{someVariable}}"></some-component>) to another element (ex. <another-component another-property="[[someVariable]]"></another-component>).

Update Dependencies When Switching Branches

(fix for nothing showing or items missing)

When switching branches, the dependencies may change. This means you need to update (bower install) all dependencies again. You may not need to do this when switching between branches which are relatively similar, but for branches with significant differences (ex. master vs mvp) you'll definitely need to update your dependencies again.

Resolving Git Push Permission error

(unable to push changes from local repo up to remote repository)

If unable to successfully push changes and receive the message: remote - Permission to F4IF/ctree-demo.git denied to [github username], then run the following command:

git remote set-url origin "https://@github.com/F4IF/ctree-demo.git"

Try pushing new local branch up with:

git push --set-upstream origin