-
-
Notifications
You must be signed in to change notification settings - Fork 926
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve handling of is-elements and Fix tiny bugs of setAttr()/update…
…Style() (#2988) * setAttr/removeAttr: remove `key === "is"`, fixes #2799 This allows the "is" attribute to be set or removed like any other attribute. * swap set and removal order of attributes/style properties * bypass css text This is a leftover from #2811. * Vnode: add vnode.is to handle is-element This seems to give better performance than simply adding a `(old.attrs && old.attrs.is) == (vnode.attrs && vnode.attrs.is)` evaluation to updateNode(). * refactor isEmpty() * move `old.is === vnode.is` evaluation to the top of updateNode() It seems better to evaluate `old.is === vnode.is` before process that assumes node update. * revert isEmpty() back * hasPropertyKey: evaluate `vnode.is` instead of `vnode.attrs.is` * execSelector: use `attrs.is != null` instead of `hasOwn.call(attrs, "is")` * Vnode: initialize `is` with undefined * add manual test * Update hyperscript.js Signed-off-by: Claudia Meadows <[email protected]> --------- Signed-off-by: Claudia Meadows <[email protected]> Co-authored-by: Claudia Meadows <[email protected]>
- Loading branch information
1 parent
f5fc394
commit 2f56c8e
Showing
6 changed files
with
247 additions
and
26 deletions.
There are no files selected for viewing
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
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
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
</head> | ||
<body> | ||
<p>This is a test for special case-handling of attribute and style properties. (#2988).</p> | ||
<p>Open your browser's Developer Console and follow these steps:</p> | ||
<ol> | ||
<li>Check the background color of the "foo" below.</li> | ||
<ul> | ||
<li>If it is light green, it is correct. The style has been updated properly.</li> | ||
<li>If it is red or yellow, the style has not been updated properly.</li> | ||
</ul> | ||
<li>Check the logs displayed in the console.</li> | ||
<ul> | ||
<li>If the attribute has been updated correctly, you should see the following message: "If you see this message, the update process is correct."</li> | ||
<li>If "null" is displayed, the attribute has not been updated properly.</li> | ||
</ul> | ||
</ol> | ||
|
||
<div id="root" style="background-color: red;"></div> | ||
<script src="../../../mithril.js"></script> | ||
<script> | ||
// data-*** is NOT case-sensitive | ||
// style properties have two cases (camelCase and dash-case) | ||
var a = m("div#a", {"data-sampleId": "If you see this message, something is wrong.", style: {backgroundColor: "yellow"}}, "foo") | ||
var b = m("div#a", {"data-sampleid": "If you see this message, the update process is correct.", style: {"background-color": "lightgreen"}}, "foo") | ||
|
||
// background color is yellow | ||
m.render(document.getElementById("root"), a) | ||
|
||
// background color is lightgreen? | ||
m.render(document.getElementById("root"), b) | ||
|
||
// data-sampleid is "If you see this message, the update process is correct."? | ||
console.log(document.querySelector("#a").getAttribute("data-sampleid")) | ||
</script> | ||
</body> | ||
</html> |
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
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
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