Skip to content

Commit 2bc3a84

Browse files
authored
Merge pull request #81 from botandrose/prettier
Add prettier to normalize code style
2 parents a42245d + 0fe1abc commit 2bc3a84

File tree

14 files changed

+2912
-2537
lines changed

14 files changed

+2912
-2537
lines changed

.prettierignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
node_modules/
2+
dist/
3+
coverage/
4+
test/*/*
5+
!test/lib
6+
package.json
7+
package-lock.json
8+
tsconfig.json
9+
*.md
10+
.github
11+

package-lock.json

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
"gen-modules": "npm run-script amd && npm run-script cjs && npm run-script esm",
3030
"dist": "cp -r src/* dist/ && cat src/idiomorph.js src/idiomorph-htmx.js > dist/idiomorph-ext.js && npm run-script gen-modules && npm run-script uglify && gzip -9 -k -f dist/idiomorph.min.js > dist/idiomorph.min.js.gz && exit",
3131
"uglify": "uglifyjs -m eval -o dist/idiomorph.min.js dist/idiomorph.js && uglifyjs -m eval -o dist/idiomorph-ext.min.js dist/idiomorph-ext.js",
32+
"format": "prettier --write .",
33+
"format-check": "prettier --check .",
3234
"typecheck": "tsc"
3335
},
3436
"repository": {
@@ -43,6 +45,7 @@
4345
"fs-extra": "^9.1.0",
4446
"htmx.org": "1.9.9",
4547
"p-wait-for": "^5.0.2",
48+
"prettier": "^3.4.2",
4649
"sinon": "^9.2.4",
4750
"typescript": "^5.3.3",
4851
"uglify-js": "^3.15.0"

src/idiomorph-htmx.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
(function(){
2-
function createMorphConfig(swapStyle) {
3-
if (swapStyle === 'morph' || swapStyle === 'morph:outerHTML') {
4-
return {morphStyle: 'outerHTML'}
5-
} else if (swapStyle === 'morph:innerHTML') {
6-
return {morphStyle: 'innerHTML'}
7-
} else if (swapStyle.startsWith("morph:")) {
8-
return Function("return (" + swapStyle.slice(6) + ")")();
9-
}
1+
(function () {
2+
function createMorphConfig(swapStyle) {
3+
if (swapStyle === "morph" || swapStyle === "morph:outerHTML") {
4+
return { morphStyle: "outerHTML" };
5+
} else if (swapStyle === "morph:innerHTML") {
6+
return { morphStyle: "innerHTML" };
7+
} else if (swapStyle.startsWith("morph:")) {
8+
return Function("return (" + swapStyle.slice(6) + ")")();
109
}
10+
}
1111

12-
htmx.defineExtension('morph', {
13-
isInlineSwap: function(swapStyle) {
14-
let config = createMorphConfig(swapStyle);
15-
return config?.morphStyle === "outerHTML" || config?.morphStyle == null;
16-
},
17-
handleSwap: function (swapStyle, target, fragment) {
18-
let config = createMorphConfig(swapStyle);
19-
if (config) {
20-
return Idiomorph.morph(target, fragment.children, config);
21-
}
22-
}
23-
});
24-
})()
12+
htmx.defineExtension("morph", {
13+
isInlineSwap: function (swapStyle) {
14+
let config = createMorphConfig(swapStyle);
15+
return config?.morphStyle === "outerHTML" || config?.morphStyle == null;
16+
},
17+
handleSwap: function (swapStyle, target, fragment) {
18+
let config = createMorphConfig(swapStyle);
19+
if (config) {
20+
return Idiomorph.morph(target, fragment.children, config);
21+
}
22+
},
23+
});
24+
})();

0 commit comments

Comments
 (0)