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

Ensure className bindings work correctly when ShadyDOM.noPatch is… #5518

Merged
merged 9 commits into from
Apr 20, 2019
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
5 changes: 4 additions & 1 deletion lib/legacy/polymer.dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ class DomApiNative {
* @param {Node} node Node for which to create a Polymer.dom helper object.
*/
constructor(node) {
if (window['ShadyDOM'] && window['ShadyDOM']['inUse']) {
window['ShadyDOM']['patch'](node);
}
this.node = node;
}

Expand Down Expand Up @@ -441,7 +444,7 @@ if (window['ShadyDOM'] && window['ShadyDOM']['inUse'] && window['ShadyDOM']['noP
]);

forwardProperties(DomApiNative.prototype, [
'textContent', 'innerHTML'
'textContent', 'innerHTML', 'className'
]);
}

Expand Down
10 changes: 10 additions & 0 deletions lib/mixins/property-effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,12 @@ function setupCompoundStorage(node, binding) {
storage[target] = literals;
// Configure properties with their literal parts
if (binding.literal && binding.kind == 'property') {
// Note, className needs style scoping so this needs wrapping.
// We may also want to consider doing this for `textContent` and
// `innerHTML`.
if (target === 'className') {
node = wrap(node);
}
node[target] = binding.literal;
}
}
Expand Down Expand Up @@ -1407,6 +1413,10 @@ export const PropertyEffects = dedupingMixin(superClass => {
// implement a whitelist of tag & property values that should never
// be reset (e.g. <input>.value && <select>.value)
if (value !== node[prop] || typeof value == 'object') {
// Note, className needs style scoping so this needs wrapping.
if (prop === 'className') {
node = /** @type {!Node} */(wrap(node));
}
node[prop] = value;
}
}
Expand Down
3 changes: 2 additions & 1 deletion lib/utils/wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
* @type {function(Node):Node}
*/
export const wrap = (window['ShadyDOM'] && window['ShadyDOM']['noPatch'] && window['ShadyDOM']['wrap']) ?
window['ShadyDOM']['wrap'] : (n) => n;
window['ShadyDOM']['wrap'] :
(window['ShadyDOM'] ? (n) => ShadyDOM['patch'](n) : (n) => n);

Loading