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

Rebase sanitize dom value getter onto legacy-undefined-noBatch #5618

Merged
merged 2 commits into from
Jan 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions lib/utils/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,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;
Expand All @@ -73,13 +73,22 @@ export let 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
Expand Down
9 changes: 8 additions & 1 deletion test/unit/property-effects.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<script type="module">
import './property-effects-elements.js';
import { Polymer, html } from '../../polymer-legacy.js';
import { setSanitizeDOMValue, sanitizeDOMValue, setLegacyWarnings, legacyUndefined, setLegacyUndefined, setOrderedComputed, orderedComputed } from '../../lib/utils/settings.js';
import { setSanitizeDOMValue, sanitizeDOMValue, getSanitizeDOMValue, setLegacyWarnings, legacyUndefined, setLegacyUndefined, setOrderedComputed, orderedComputed } from '../../lib/utils/settings.js';
import { PropertyEffects } from '../../lib/mixins/property-effects.js';
import { flush } from '../../lib/utils/flush.js';

Expand Down Expand Up @@ -1471,6 +1471,13 @@
['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() {
Expand Down