On 31.03.22 08:36, Fabian Ebner wrote: > Am 30.03.22 um 14:59 schrieb Matthias Heiserer: >> 8< >> >>>> + onLoad: function(store, records, success, operation) { >>>> + let me = this; >>>> + let view = me.getView(); >>>> + let selection = view.getSelection()?.[0]; >>>> + selection = selection?.parentNode?.data?.text >>>> +selection?.data?.volid; >>> Style nit: missing space after + and could use `${...}${...}` syntax >>> instead. >> That syntax won't work because then, if both parameters are undefined, >> the result would be a string instead of a falsy (NaN) value. >> There's probably a better way of doing this. >>
seems odd use of side-effect, if that's relevant it could be checked more explicitly with a boolean expression (as JS "arithmetic" operations can be quite weird). Note also that `var foo = "asdf" + undefined;` makes `foo` be "asdfundefined" so are you sure that's the behavior you want? FWIW, you could also destructure an additional object level like: let { data, parentNode } = view.getSelection()?.[0] ?? {}; Could make checking explicitly easier. >>> (...) >>> >>>> + if (selection) { >>>> + let rootnode = view.getRootNode(); >>>> + let selected; >>>> + rootnode.cascade(node => { >>>> + if (selected) {return false;} // skip if already found >>> Style nit: if body on the same line >> Is 'if on one line' something we generally don't do? It appears >> occasionally in the code. > I don't think it's explicitly forbidden by our style guide, which > essentially is what the linter complains about, but in the (vast) > majority of cases, the body is on its own line. > Thanks for the hint, it's now: https://pve.proxmox.com/wiki/Javascript_Style_Guide#Single-Line_If-Statement _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel