mirror of
https://github.com/Polymer/polymer.git
synced 2026-08-17 16:34:49 -05:00
Add getSanitizeDOMValue to settings API (#5617)
* Add getSanitizeDOMValue to settings API For environments that don't well support `export let`. * Add a test for getSanitizeDOMValue
This commit is contained in:
+11
-2
@@ -49,7 +49,7 @@ export const setRootPath = function(path) {
|
||||
* `type` indicates where the value is being inserted: one of property, attribute, or text.
|
||||
* `node` is the node where the value is being inserted.
|
||||
*
|
||||
* @type {(function(*,string,string,Node):*)|undefined}
|
||||
* @type {(function(*,string,string,?Node):*)|undefined}
|
||||
*/
|
||||
export let sanitizeDOMValue = window.Polymer && window.Polymer.sanitizeDOMValue || undefined;
|
||||
|
||||
@@ -57,13 +57,22 @@ export let sanitizeDOMValue = window.Polymer && window.Polymer.sanitizeDOMValue
|
||||
* Sets the global sanitizeDOMValue available via this module's exported
|
||||
* `sanitizeDOMValue` variable.
|
||||
*
|
||||
* @param {(function(*,string,string,Node):*)|undefined} newSanitizeDOMValue the global sanitizeDOMValue callback
|
||||
* @param {(function(*,string,string,?Node):*)|undefined} newSanitizeDOMValue the global sanitizeDOMValue callback
|
||||
* @return {void}
|
||||
*/
|
||||
export const setSanitizeDOMValue = function(newSanitizeDOMValue) {
|
||||
sanitizeDOMValue = newSanitizeDOMValue;
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets sanitizeDOMValue, for environments that don't well support `export let`.
|
||||
*
|
||||
* @return {(function(*,string,string,?Node):*)|undefined} sanitizeDOMValue
|
||||
*/
|
||||
export const getSanitizeDOMValue = function() {
|
||||
return sanitizeDOMValue;
|
||||
};
|
||||
|
||||
/**
|
||||
* Globally settable property to make Polymer Gestures use passive TouchEvent listeners when recognizing gestures.
|
||||
* When set to `true`, gestures made from touch will not be able to prevent scrolling, allowing for smoother
|
||||
|
||||
@@ -26,7 +26,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
<script type="module">
|
||||
import './property-effects-elements.js';
|
||||
import { Polymer, html } from '../../polymer-legacy.js';
|
||||
import { setSanitizeDOMValue, sanitizeDOMValue, setLegacyOptimizations } from '../../lib/utils/settings.js';
|
||||
import { setSanitizeDOMValue, sanitizeDOMValue, getSanitizeDOMValue, setLegacyOptimizations } from '../../lib/utils/settings.js';
|
||||
import { PropertyEffects } from '../../lib/mixins/property-effects.js';
|
||||
|
||||
suite('single-element binding effects', function() {
|
||||
@@ -341,7 +341,7 @@ suite('single-element binding effects', function() {
|
||||
assert.equal(el.customEventObject.value, 84, 'custom bound path incorrect');
|
||||
assert.equal(el.observerCounts.customEventObjectValueChanged, 1, 'custom bound path observer not called');
|
||||
});
|
||||
|
||||
|
||||
test('custom notification bubbling event to property', function() {
|
||||
const child = document.createElement('div');
|
||||
el.$.boundChild.appendChild(child);
|
||||
@@ -1461,6 +1461,13 @@ suite('DOM sanitization', function() {
|
||||
['javascript', 'reflectedstring', 'attribute', el]);
|
||||
});
|
||||
|
||||
test('getter returns the current value', function() {
|
||||
assert(sanitizeDOMValue instanceof Function);
|
||||
assert.strictEqual(getSanitizeDOMValue(), sanitizeDOMValue);
|
||||
setSanitizeDOMValue(null);
|
||||
assert.strictEqual(sanitizeDOMValue, null);
|
||||
assert.strictEqual(getSanitizeDOMValue(), null);
|
||||
});
|
||||
});
|
||||
|
||||
suite('data (im)mutability', function() {
|
||||
|
||||
Reference in New Issue
Block a user