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

Service Worker Scope #782

Closed
FredXue opened this issue Nov 19, 2015 · 1 comment
Closed

Service Worker Scope #782

FredXue opened this issue Nov 19, 2015 · 1 comment

Comments

@FredXue
Copy link

FredXue commented Nov 19, 2015

if ('serviceWorker' in navigator) {
  navigator.serviceWorker.register('/sw-test/sw.js', { scope: '/sw-test/' }).then(function(reg) {
    // registration worked
    console.log('Registration succeeded. Scope is ' + reg.scope);
  }).catch(function(error) {
    // registration failed
    console.log('Registration failed with ' + error);
  });
};

We know the scope depends on the sw.js file's location, if the path of sw.js is '/sw-test/sw.js', then, the scope should be '/sw-test/'. So why do we need to define a scope attribute seperately?
I found the the scope can't be the parent directory of the SW path.

@FredXue FredXue closed this as completed Nov 19, 2015
@FredXue FredXue reopened this Nov 19, 2015
@FredXue
Copy link
Author

FredXue commented Nov 19, 2015

I found my answer on #595

@FredXue FredXue closed this as completed Nov 19, 2015
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

No branches or pull requests

1 participant