Skip to content

Commit

Permalink
format js (npx eslint --fix)
Browse files Browse the repository at this point in the history
  • Loading branch information
SteffenDE committed Nov 18, 2024
1 parent bcbb875 commit 6784005
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion assets/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,4 @@ module.exports = {

// Whether to use watchman for file crawling
// watchman: true,
};
}
4 changes: 2 additions & 2 deletions assets/js/phoenix_live_view/aria.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ let ARIA = {
anyOf(instance, classes){ return classes.find(name => instance instanceof name) },

isFocusable(el, interactiveOnly){
return(
return (
(el instanceof HTMLAnchorElement && el.rel !== "ignore") ||
(el instanceof HTMLAreaElement && el.href !== undefined) ||
(!el.disabled && (this.anyOf(el, [HTMLInputElement, HTMLSelectElement, HTMLTextAreaElement, HTMLButtonElement]))) ||
Expand All @@ -12,7 +12,7 @@ let ARIA = {
},

attemptFocus(el, interactiveOnly){
if(this.isFocusable(el, interactiveOnly)){ try{ el.focus() } catch(e){} }
if(this.isFocusable(el, interactiveOnly)){ try { el.focus() } catch (e){} }
return !!document.activeElement && document.activeElement.isSameNode(el)
},

Expand Down
8 changes: 4 additions & 4 deletions assets/js/phoenix_live_view/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ let DOM = {

try {
url = new URL(href)
} catch(e) {
} catch (e){
try {
url = new URL(href, currentLocation)
} catch(e) {
} catch (e){
// bad URL, fallback to let browser try it as external
return true
}
Expand Down Expand Up @@ -514,7 +514,7 @@ let DOM = {
},

getSticky(el, name, defaultVal){
let op = (DOM.private(el, "sticky") || []).find(([existingName, ]) => name === existingName)
let op = (DOM.private(el, "sticky") || []).find(([existingName,]) => name === existingName)
if(op){
let [_name, _op, stashedResult] = op
return stashedResult
Expand All @@ -532,7 +532,7 @@ let DOM = {
putSticky(el, name, op){
let stashedResult = op(el)
this.updatePrivate(el, "sticky", [], ops => {
let existingIndex = ops.findIndex(([existingName, ]) => name === existingName)
let existingIndex = ops.findIndex(([existingName,]) => name === existingName)
if(existingIndex >= 0){
ops[existingIndex] = [name, op, stashedResult]
} else {
Expand Down
4 changes: 2 additions & 2 deletions assets/js/phoenix_live_view/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ let Hooks = {
let findScrollContainer = (el) => {
// the scroll event won't be fired on the html/body element even if overflow is set
// therefore we return null to instead listen for scroll events on document
if (["HTML", "BODY"].indexOf(el.nodeName.toUpperCase()) >= 0) return null
if(["HTML", "BODY"].indexOf(el.nodeName.toUpperCase()) >= 0) return null
if(["scroll", "auto"].indexOf(getComputedStyle(el).overflowY) >= 0) return el
return findScrollContainer(el.parentElement)
}
Expand Down Expand Up @@ -204,7 +204,7 @@ Hooks.InfiniteScroll = {
let remainingTime = interval - (now - lastCallAt)

if(remainingTime <= 0 || remainingTime > interval){
if(timer) {
if(timer){
clearTimeout(timer)
timer = null
}
Expand Down
2 changes: 1 addition & 1 deletion assets/js/phoenix_live_view/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ export {
LiveSocket,
isUsedInput,
createHook
}
}
18 changes: 9 additions & 9 deletions assets/js/phoenix_live_view/rendered.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ const VOID_TAGS = new Set([
"track",
"wbr"
])
const quoteChars = new Set(["'", '"'])
const quoteChars = new Set(["'", "\""])

export let modifyRoot = (html, attrs, clearInnerHTML) => {
let i = 0
let insideComment = false
let beforeTag, afterTag, tag, tagNameEndsAt, id, newHTML

let lookahead = html.match(/^(\s*(?:<!--.*?-->\s*)*)<([^\s\/>]+)/)
if(lookahead === null) { throw new Error(`malformed html ${html}`) }
if(lookahead === null){ throw new Error(`malformed html ${html}`) }

i = lookahead[0].length
beforeTag = lookahead[1]
Expand All @@ -57,15 +57,15 @@ export let modifyRoot = (html, attrs, clearInnerHTML) => {
if(html.charAt(i) === ">" ){ break }
if(html.charAt(i) === "="){
let isId = html.slice(i - 3, i) === " id"
i++;
i++
let char = html.charAt(i)
if (quoteChars.has(char)) {
if(quoteChars.has(char)){
let attrStartsAt = i
i++
for(i; i < html.length; i++){
if(html.charAt(i) === char){ break }
}
if (isId) {
if(isId){
id = html.slice(attrStartsAt + 1, i)
break
}
Expand Down Expand Up @@ -97,12 +97,12 @@ export let modifyRoot = (html, attrs, clearInnerHTML) => {

let attrsStr =
Object.keys(attrs)
.map(attr => attrs[attr] === true ? attr : `${attr}="${attrs[attr]}"`)
.join(" ")
.map(attr => attrs[attr] === true ? attr : `${attr}="${attrs[attr]}"`)
.join(" ")

if(clearInnerHTML){
// Keep the id if any
let idAttrStr = id ? ` id="${id}"` : "";
let idAttrStr = id ? ` id="${id}"` : ""
if(VOID_TAGS.has(tag)){
newHTML = `<${tag}${idAttrStr}${attrsStr === "" ? "" : " "}${attrsStr}/>`
} else {
Expand Down Expand Up @@ -280,7 +280,7 @@ export default class Rendered {
isNewFingerprint(diff = {}){ return !!diff[STATIC] }

templateStatic(part, templates){
if(typeof (part) === "number") {
if(typeof (part) === "number"){
return templates[part]
} else {
return part
Expand Down
10 changes: 5 additions & 5 deletions assets/js/phoenix_live_view/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,7 @@ export default class View {
})
}
}
el.dispatchEvent(new CustomEvent(`phx:push`, {
el.dispatchEvent(new CustomEvent("phx:push", {
detail: detail,
bubbles: true,
cancelable: false
Expand Down Expand Up @@ -1312,11 +1312,11 @@ export default class View {
let uploader = new LiveUploader(inputEl, this, () => {
numFileInputsInProgress--
if(numFileInputsInProgress === 0){ onComplete() }
});
})

let entries = uploader.entries().map(entry => entry.toPreflightPayload())

if(entries.length === 0) {
if(entries.length === 0){
numFileInputsInProgress--
return
}
Expand Down Expand Up @@ -1377,11 +1377,11 @@ export default class View {
else { DOM.dispatchEvent(inputs[0], PHX_TRACK_UPLOADS, {detail: {files: filesOrBlobs}}) }
}

targetCtxElement(targetCtx) {
targetCtxElement(targetCtx){
if(isCid(targetCtx)){
let [target] = DOM.findComponentNodeList(this.el, targetCtx)
return target
} else if(targetCtx) {
} else if(targetCtx){
return targetCtx
} else {
return null
Expand Down
20 changes: 10 additions & 10 deletions assets/js/phoenix_live_view/view_hook.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,35 +253,35 @@ export default class ViewHook {
}

pushEvent(event, payload = {}, onReply){
if (onReply === undefined) {
if(onReply === undefined){
return new Promise((resolve, reject) => {
try {
const ref = this.__view().pushHookEvent(this.el, null, event, payload, (reply, _ref) => resolve(reply));
if (ref === false) {
const ref = this.__view().pushHookEvent(this.el, null, event, payload, (reply, _ref) => resolve(reply))
if(ref === false){
reject(new Error("unable to push hook event. LiveView not connected"))
}
} catch (error) {
} catch (error){
reject(error)
}
});
})
}
return this.__view().pushHookEvent(this.el, null, event, payload, onReply)
}

pushEventTo(phxTarget, event, payload = {}, onReply){
if (onReply === undefined) {
if(onReply === undefined){
return new Promise((resolve, reject) => {
try {
this.__view().withinTargets(phxTarget, (view, targetCtx) => {
const ref = view.pushHookEvent(this.el, targetCtx, event, payload, (reply, _ref) => resolve(reply))
if (ref === false) {
if(ref === false){
reject(new Error("unable to push hook event. LiveView not connected"))
}
})
} catch (error) {
} catch (error){
reject(error)
}
});
})
}
return this.__view().withinTargets(phxTarget, (view, targetCtx) => {
return view.pushHookEvent(this.el, targetCtx, event, payload, onReply)
Expand Down Expand Up @@ -314,4 +314,4 @@ export default class ViewHook {
__cleanup__(){
this.__listeners.forEach(callbackRef => this.removeHandleEvent(callbackRef))
}
}
}
4 changes: 2 additions & 2 deletions assets/setupTests.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import 'regenerator-runtime/runtime'
import 'css.escape'
import "regenerator-runtime/runtime"
import "css.escape"

0 comments on commit 6784005

Please sign in to comment.