This repository has been archived by the owner on Sep 20, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 63
Cooperate with ShadyCSS to appropriately scope changes to class/className #54
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
2fbc952
Cooperate with ShadyCSS to scope class/className
c1d7605
Merge branch 'master' into class-scoping
caafb7d
Remove unused add/remove hooks no longer needed for dynamic styling.
b056e5f
Distribute based on attribute change if (1) the node is a `slot` and …
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ let mixinImpl = { | |
let ownerRoot = this.ownerShadyRootForNode(container); | ||
if (ownerRoot) { | ||
// optimization: special insertion point tracking | ||
if (node.__noInsertionPoint) { | ||
if (node.__noInsertionPoint && ownerRoot._clean) { | ||
ownerRoot._skipUpdateInsertionPoints = true; | ||
} | ||
// note: we always need to see if an insertion point is added | ||
|
@@ -33,7 +33,6 @@ let mixinImpl = { | |
if (ipAdded) { | ||
ownerRoot._skipUpdateInsertionPoints = false; | ||
} | ||
this._addedNode(node, ownerRoot); | ||
} | ||
if (tree.Logical.hasChildNodes(container)) { | ||
tree.Logical.recordInsertBefore(node, container, ref_node); | ||
|
@@ -66,9 +65,6 @@ let mixinImpl = { | |
} | ||
} | ||
this._removeOwnerShadyRoot(node); | ||
if (ownerRoot) { | ||
this._removedNode(node, ownerRoot); | ||
} | ||
return distributed; | ||
}, | ||
|
||
|
@@ -200,23 +196,6 @@ let mixinImpl = { | |
node.shadyRoot.hasInsertionPoint(); | ||
}, | ||
|
||
// TODO(sorvell): needed for style scoping, use MO? | ||
_addedNode() {}, | ||
_removedNode() {}, | ||
/* | ||
_addedNode(node, root) { | ||
// if (ShadyDOM.addedNode) { | ||
// ShadyDOM.addedNode(node, root); | ||
// } | ||
}, | ||
|
||
_removedNode(node, root) { | ||
if (ShadyDOM.removedNode) { | ||
ShadyDOM.removedNode(node, root); | ||
} | ||
}, | ||
*/ | ||
|
||
_removeDistributedChildren(root, container) { | ||
let hostNeedsDist; | ||
let ip$ = root._insertionPoints; | ||
|
@@ -286,10 +265,11 @@ let mixinImpl = { | |
}, | ||
|
||
maybeDistributeAttributeChange(node, name) { | ||
let distribute = (node.localName === 'slot' && name === 'name'); | ||
if (distribute) { | ||
let root = this.getRootNode(node); | ||
if (root.update) { | ||
if (name === 'slot') { | ||
this.maybeDistributeParent(node); | ||
} else if (node.localName === 'slot' && name === 'name') { | ||
let root = this.ownerShadyRootForNode(node); | ||
if (root) { | ||
root.update(); | ||
} | ||
} | ||
|
@@ -371,6 +351,14 @@ let nativeImportNode = Document.prototype.importNode; | |
let nativeSetAttribute = Element.prototype.setAttribute; | ||
let nativeRemoveAttribute = Element.prototype.removeAttribute; | ||
|
||
export let setAttribute = function(attr, value) { | ||
if (window.ShadyCSS && attr === 'class') { | ||
window.ShadyCSS.setElementClass(this, value); | ||
} else { | ||
nativeSetAttribute.call(this, attr, value); | ||
} | ||
} | ||
|
||
let NodeMixin = {}; | ||
|
||
Object.defineProperties(NodeMixin, { | ||
|
@@ -656,17 +644,13 @@ let ElementMixin = { | |
|
||
|
||
setAttribute(name, value) { | ||
nativeSetAttribute.call(this, name, value); | ||
if (!mixinImpl.maybeDistributeParent(this)) { | ||
mixinImpl.maybeDistributeAttributeChange(this, name); | ||
} | ||
setAttribute.call(this, name, value); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could be |
||
mixinImpl.maybeDistributeAttributeChange(this, name); | ||
}, | ||
|
||
removeAttribute(name) { | ||
nativeRemoveAttribute.call(this, name); | ||
if (!mixinImpl.maybeDistributeParent(this)) { | ||
mixinImpl.maybeDistributeAttributeChange(this, name); | ||
} | ||
mixinImpl.maybeDistributeAttributeChange(this, name); | ||
} | ||
|
||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not take the node as the first argument?
setAttribute(node, attr, value)
would remove the indirection used later.