Skip to content

Commit 3183e3f

Browse files
committed
Add lib/utils/settings.html to hold legacy settings and rootPath
1 parent 3380c78 commit 3183e3f

File tree

3 files changed

+66
-23
lines changed

3 files changed

+66
-23
lines changed

lib/legacy/polymer.dom.html

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
99
-->
1010
<link rel="import" href="../utils/boot.html">
11+
<link rel="import" href="../utils/settings.html">
1112
<link rel="import" href="../utils/flattened-nodes-observer.html">
1213
<link rel="import" href="../utils/flush.html">
1314
<script>
@@ -322,15 +323,5 @@
322323
* @param {Polymer.Debouncer} debouncer Debouncer to enqueue
323324
*/
324325
Polymer.dom.addDebouncer = Polymer.enqueueDebouncer;
325-
326-
// expose BC settings.
327-
let settings = Polymer.Settings || {};
328-
settings.useShadow = !(window.ShadyDOM);
329-
settings.useNativeCSSProperties =
330-
Boolean(!window.ShadyCSS || window.ShadyCSS.nativeCss);
331-
settings.useNativeCustomElements =
332-
!(window.customElements.polyfillWrapFlushCallback);
333-
Polymer.Settings = settings;
334-
335326
})();
336327
</script>

lib/mixins/element-mixin.html

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
-->
1010

1111
<link rel="import" href="../utils/boot.html">
12+
<link rel="import" href="../utils/settings.html">
1213
<link rel="import" href="../utils/mixin.html">
1314
<link rel="import" href="../utils/case-map.html">
1415
<link rel="import" href="../utils/style-gather.html">
@@ -848,18 +849,5 @@
848849
}
849850
};
850851

851-
/**
852-
* Globally settable property that is automatically assigned to
853-
* `Polymer.ElementMixin` instances, useful for binding in templates to
854-
* make URL's relative to an application's root. Defaults to the main
855-
* document URL, but can be overridden by users. It may be useful to set
856-
* `Polymer.rootPath` to provide a stable application mount path when
857-
* using client side routing.
858-
*
859-
* @memberof Polymer
860-
*/
861-
Polymer.rootPath = Polymer.rootPath ||
862-
Polymer.ResolveUrl.pathFromUrl(document.baseURI || window.location.href);
863-
864852
})();
865853
</script>

lib/utils/settings.html

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<!--
2+
@license
3+
Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
4+
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
5+
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6+
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
7+
Code distributed by Google as part of the polymer project is also
8+
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
9+
-->
10+
11+
<link rel="import" href="../utils/boot.html">
12+
<link rel="import" href="../utils/resolve-url.html">
13+
14+
<script>
15+
(function() {
16+
'use strict';
17+
18+
/**
19+
* Legacy settings.
20+
* @namespace
21+
* @memberof Polymer
22+
*/
23+
const settings = Polymer.Settings || {};
24+
settings.useShadow = !(window.ShadyDOM);
25+
settings.useNativeCSSProperties =
26+
Boolean(!window.ShadyCSS || window.ShadyCSS.nativeCss);
27+
settings.useNativeCustomElements =
28+
!(window.customElements.polyfillWrapFlushCallback);
29+
30+
/**
31+
* Sets the global, legacy settings.
32+
*
33+
* @deprecated
34+
* @memberof Polymer
35+
*/
36+
Polymer.Settings = settings;
37+
38+
/**
39+
* Globally settable property that is automatically assigned to
40+
* `Polymer.ElementMixin` instances, useful for binding in templates to
41+
* make URL's relative to an application's root. Defaults to the main
42+
* document URL, but can be overridden by users. It may be useful to set
43+
* `Polymer.rootPath` to provide a stable application mount path when
44+
* using client side routing.
45+
*
46+
* @memberof Polymer
47+
*/
48+
let rootPath = Polymer.rootPath ||
49+
Polymer.ResolveUrl.pathFromUrl(document.baseURI || window.location.href);
50+
51+
Polymer.rootPath = rootPath;
52+
53+
/**
54+
* Sets the global rootPath property used by `Polymer.ElementMixin` and
55+
* available via `Polymer.rootPath`.
56+
*
57+
* @memberof Polymer
58+
* @param {string} path The new root path
59+
*/
60+
Polymer.setRootPath = function(path) {
61+
Polymer.rootPath = path;
62+
}
63+
})();
64+
</script>

0 commit comments

Comments
 (0)