Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

[0.8] Global settings overwritten by webcomponents #1017

Closed
arthurevans opened this issue Apr 13, 2015 · 4 comments
Closed

[0.8] Global settings overwritten by webcomponents #1017

arthurevans opened this issue Apr 13, 2015 · 4 comments
Assignees

Comments

@arthurevans
Copy link

From @clintwood on April 13, 2015 12:3

Just in case someone else bumps up against this...

The documentation states that global settings should be the first script in the main document. So one would tend to do the following:

  <head>
    <title>Polymer Sample</title>
    <script>Polymer = {dom: 'shadow'};</script>
    <script src="./bower_components/webcomponentsjs/webcomponents.js"></script>
    <!-- <script>Polymer = {dom: 'shadow'};</script> -->
    <link rel="import" href="./bower_components/polymer/polymer.html">
  </head>

However, webcomponents.js overwrites the global Polymer variable.

This is not the case when following the 0.8-preview recommendation to use webcomponents-lite.js.

Alternatively you can move the script tag that declares the Polymer variable to just above the import link tag (as show in the commented script tag above).

Copied from original issue: Polymer/polymer#1404

@arthurevans arthurevans self-assigned this Apr 13, 2015
@arthurevans
Copy link
Author

Good catch -- thanks. Will fix.

@arthurevans
Copy link
Author

Note that in order to not break the stub installed by webcomponents.js (specifically the html imports polyfill, I think), we should probably set window.Polymer.dom = 'shadow' -- or something to that effect.

@arthurevans
Copy link
Author

@sorvell Is this stub still useful with 0.8, or is it unnecessary?

I'm inclined to rewrite the sample code this way:

<html>
  <head>
   <meta charset="utf-8">
   <script src="components/webcomponentsjs/webcomponents-lite.js"></script>
  <script>
     window.Polymer = window.Polymer || {};
     window.Polymer.dom = 'shadow';
   </script>
   <!-- import a component that relies on Polymer -->
   <link rel="import" href="elements/my-app.html">
 </head>

But if the stub isn't required at all for 0.8, we could just overwrite the object and not worry about it.

@arthurevans
Copy link
Author

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

No branches or pull requests

1 participant