summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2019-10-06 11:41:15 +0200
committerYorhel <git@yorhel.nl>2019-10-06 11:41:17 +0200
commit69ffbc08f489770863b80998c704c66f148e469e (patch)
tree849d4d1bca0a13814b4795274f9a5743c05df036 /Makefile
parent1bed2ce042bab94823550cd90b4e0883710e65de (diff)
Elm: Support arbitrary id types in inputSelect + actually honor the selected option
Elm has a bug where the 'selected' attribute is not properly propagated, that's fixed by patching the generated JS. Also moved Ffi.js one level up, as it's important that that file is loaded before any Elm modules are initialized.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile17
1 files changed, 11 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index 71fb3f4a..2cbc4511 100644
--- a/Makefile
+++ b/Makefile
@@ -116,10 +116,15 @@ static/f/vndb.min.js: static/f/vndb.js
# v2-rw
-define cat-js
+# Patch the Javascript generated by Elm and append the elm/**.js files to it.
+# Patches include:
+# - Redirect calls from Lib.Ffi.* to window.elmFfi_*
+# - Patch the virtualdom diffing algorithm to always apply the 'selected' attribute
+define fix-js
sed -i 's/var author\$$project\$$Lib\$$Ffi\$$/var __unused__/g' $@
sed -Ei 's/author\$$project\$$Lib\$$Ffi\$$([a-zA-Z0-9_]+)/window.elmFfi_\1(_Json_wrap)/g' $@
- for fn in elm/*.js elm/*/*.js; do \
+ sed -Ei "s/([^ ]+) !== 'checked'/\\1 !== 'checked' \&\& \\1 !== 'selected'/g" $@
+ for fn in elm/*.js; do \
echo "(function(){'use strict';"; \
cat $$fn; \
echo "})();"; \
@@ -129,13 +134,13 @@ endef
elm/Gen/.generated: lib/VNWeb/*.pm lib/VNWeb/*/*.pm lib/VNDB/Types.pm lib/VNDB/Config.pm data/conf.pl
util/vndb.pl elmgen
-static/f/v2rw.js: elm/*.elm elm/*/*.elm elm/*.js elm/*/*.js elm/Gen/.generated | static/f
+static/f/v2rw.js: elm/*.elm elm/*/*.elm elm/*.js elm/Gen/.generated | static/f
cd elm && ELM_HOME=elm-stuff elm make *.elm */*.elm --output ../$@
- ${cat-js}
+ ${fix-js}
-static/f/v2rw.min.js: elm/*.elm elm/*/*.elm elm/*.js elm/*/*.js elm/Gen/.generated | static/f
+static/f/v2rw.min.js: elm/*.elm elm/*/*.elm elm/*.js elm/Gen/.generated | static/f
cd elm && ELM_HOME=elm-stuff elm make --optimize *.elm */*.elm --output ../$@
- ${cat-js}
+ ${fix-js}
uglifyjs $@ --compress 'pure_funcs="F2,F3,F4,F5,F6,F7,F8,F9,A2,A3,A4,A5,A6,A7,A8,A9",pure_getters,keep_fargs=false,unsafe_comps,unsafe' | uglifyjs --mangle -o $@~
mv $@~ $@