The error message related to the case where one mistakenly provide a node property that is equal (or evaluated to) null to the init method when creating an Elm application is somewhat misleading because even though the node property is provided (and it does not point to any valid DOM element) it tells the user that it should use the node property, which is already the case and the error message does not really help pinpoint exactly where the error is.
SSCCE
<html>
<head>
<style>
/* you can style your program here */
</style>
</head>
<body>
<!-- The Elm node below -->
<article></article>
<script>
var app = Elm.Main.init({ node: document.querySelector('main') })
// The node "main" does not exist and this call is equal to null
</script>
</body>
</html>
Elm: 0.19.1
Browser: Google Chrome 101
Operating System: ArchLinux
Additional Details
I didn't dive in the source-code, but I guess there should be two (or more) error messages here.
Elm.Main.init();
// First error when the first argument is missing
Elm.Main.init([]);
// Second error when the first argument is not an object
Elm.Main.init({});
// Third error when the object is provided but the node property is missing (when using Browser.* that expect a node...)
Elm.Main.init({node: null});
// Fourth error when the object is provided and the node property is provided but the node is not equal to an instanceof Element
Elm.Main.init({node: document.getElementById("elm"), happy: false});
// Fifth error when there are properties that are not expected
Of course replacing those error message with all the great error messages design that makes Elm a delight to use!
Quick Summary:
The error message related to the case where one mistakenly provide a
node
property that is equal (or evaluated to) null to theinit
method when creating an Elm application is somewhat misleading because even though thenode
property is provided (and it does not point to any valid DOM element) it tells the user that it should use thenode
property, which is already the case and the error message does not really help pinpoint exactly where the error is.SSCCE
Additional Details
I didn't dive in the source-code, but I guess there should be two (or more) error messages here.
Of course replacing those error message with all the great error messages design that makes Elm a delight to use!