fphilipe / PageExtender.app

Safari extension that injects custom CSS and JS files based on page host.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Order of files loaded

ernstwi opened this issue · comments

Hi!

I noticed while working on #7 that the order in which files are loaded is undefined. I think it would be good if users can rely on a particular order, especially with #7 but maybe even without it. It seems like this might be intended from the code as well, since the list of "basenames" is reversed so that default comes first.

I tried a bit but didn't see immediately what would be the cleanest way to fix this. Right now a dictionary of filename: contents is passed from SafariExtensionHandler.swiftto script.js. My thought was to replace this with an array of (filename, contents) tuples, but you can't pass a tuple array to JavaScript I think.

I've enjoyed using the app and looking at the code, thank you.

The Swift dictionary preserves insertion order. But when the dictionary is passed to the JS script, it gets represented as a JS object, which doesn't preserve insertion order.

Your approach with a tuple would work. I wonder if instead of a tuple we'd need to use an array instead or if the bridging takes care of that.

Feel free to take a stab at this, I'd be happy to merge this (independently of #7) 😊