Skip to content

Commit

Permalink
Add lib/utils/settings.html to hold legacy settings and rootPath
Browse files Browse the repository at this point in the history
  • Loading branch information
justinfagnani committed Jun 6, 2017
1 parent 3380c78 commit 3183e3f
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 23 deletions.
11 changes: 1 addition & 10 deletions lib/legacy/polymer.dom.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<link rel="import" href="../utils/boot.html">
<link rel="import" href="../utils/settings.html">
<link rel="import" href="../utils/flattened-nodes-observer.html">
<link rel="import" href="../utils/flush.html">
<script>
Expand Down Expand Up @@ -322,15 +323,5 @@
* @param {Polymer.Debouncer} debouncer Debouncer to enqueue
*/
Polymer.dom.addDebouncer = Polymer.enqueueDebouncer;

// expose BC settings.
let settings = Polymer.Settings || {};
settings.useShadow = !(window.ShadyDOM);
settings.useNativeCSSProperties =
Boolean(!window.ShadyCSS || window.ShadyCSS.nativeCss);
settings.useNativeCustomElements =
!(window.customElements.polyfillWrapFlushCallback);
Polymer.Settings = settings;

})();
</script>
14 changes: 1 addition & 13 deletions lib/mixins/element-mixin.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
-->

<link rel="import" href="../utils/boot.html">
<link rel="import" href="../utils/settings.html">
<link rel="import" href="../utils/mixin.html">
<link rel="import" href="../utils/case-map.html">
<link rel="import" href="../utils/style-gather.html">
Expand Down Expand Up @@ -848,18 +849,5 @@
}
};

/**
* Globally settable property that is automatically assigned to
* `Polymer.ElementMixin` instances, useful for binding in templates to
* make URL's relative to an application's root. Defaults to the main
* document URL, but can be overridden by users. It may be useful to set
* `Polymer.rootPath` to provide a stable application mount path when
* using client side routing.
*
* @memberof Polymer
*/
Polymer.rootPath = Polymer.rootPath ||
Polymer.ResolveUrl.pathFromUrl(document.baseURI || window.location.href);

})();
</script>
64 changes: 64 additions & 0 deletions lib/utils/settings.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<!--
@license
Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->

<link rel="import" href="../utils/boot.html">
<link rel="import" href="../utils/resolve-url.html">

<script>
(function() {
'use strict';

/**
* Legacy settings.
* @namespace
* @memberof Polymer
*/
const settings = Polymer.Settings || {};
settings.useShadow = !(window.ShadyDOM);
settings.useNativeCSSProperties =
Boolean(!window.ShadyCSS || window.ShadyCSS.nativeCss);
settings.useNativeCustomElements =
!(window.customElements.polyfillWrapFlushCallback);

/**
* Sets the global, legacy settings.
*
* @deprecated
* @memberof Polymer
*/
Polymer.Settings = settings;

/**
* Globally settable property that is automatically assigned to
* `Polymer.ElementMixin` instances, useful for binding in templates to
* make URL's relative to an application's root. Defaults to the main
* document URL, but can be overridden by users. It may be useful to set
* `Polymer.rootPath` to provide a stable application mount path when
* using client side routing.
*
* @memberof Polymer
*/
let rootPath = Polymer.rootPath ||
Polymer.ResolveUrl.pathFromUrl(document.baseURI || window.location.href);

Polymer.rootPath = rootPath;

/**
* Sets the global rootPath property used by `Polymer.ElementMixin` and
* available via `Polymer.rootPath`.
*
* @memberof Polymer
* @param {string} path The new root path
*/
Polymer.setRootPath = function(path) {
Polymer.rootPath = path;
}
})();
</script>

0 comments on commit 3183e3f

Please sign in to comment.