Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add permissionStatus property #32

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

FluorescentHallucinogen
Copy link
Contributor

  • Add permissionStatus property that indicates whether Geolocation API permission status is granted, denied or prompt.
  • Update code and descriptions of samples in geo-location.html, demo/index.html and README.md files.
  • Add api and permission keywords to bower.json file.
  • Fix a typo (change Gelocation to Geolocation everywhere).

@@ -11,6 +11,8 @@
"location",
"position",
"navigation",
"api",
Copy link
Owner

@ebidel ebidel Dec 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't think we need these. they're vague

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ebidel I've removed the permission keyword. But IMO we should keep the api keyword. <geo-location> web component is a part of my progressive-elements collection that is a set of web components for modern web APIs such as Payment Request API, Media Session API, etc. People can find these web components by the api keyword.

navigator.permissions.query({
name: 'geolocation'
}).then(function(permissionStatus) {
this._setPermissionStatus(permissionStatus.state);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to handle the permissions api not being available.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ebidel What should we do if Permissions API is not available?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably fail silently, but the permissionStatus needs a default value or some way to signal to users that permission state is unknown.

permissionStatus: {
type: String,
readOnly: true,
notify: true
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs a default state.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ebidel Is not the default value optional? Should I use value: null?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

null sounds good. As long as that's not one of the possible values the API returns.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean that if we do not specify a default value at all, it is equivalent to null. Should I specify it explicitly?

name: 'geolocation'
}).then(function(permissionStatus) {
this._setPermissionStatus(permissionStatus.state);
permissionStatus.onchange = function() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if this element gets attached/detached/attached from the DOM? Does permissionStatus get gc'd properly and we're not adding creating a bunch of orphaned change handlers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ebidel I don't know. Could you please help me do this in a better way?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the author of this PR, I was hoping you could do that research.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ebidel BTW, what about placing this code inside ready lifecycle callback instead of attached? Is it a bad idea?
attached can be called multiple times during the lifetime of an element. The first attached callback is guaranteed not to fire until after ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants