What are these settings in the legacy features section?
I’m currently migrating apps to use layouts, and ran into some issues after unchecking some of these. I can’t find any documentation that explains these legacy features. Should I just keep them on forever?
Include Bootstrap 3
Apply Legacy Class Names
Use legacy dict implementation
Use root DOM container
We would recommend having them on if you’ve migrated an app.
Especially if you’re using an existing theme.
In a newly created M3 (beta) app these will be all off.
Include Bootstrap 3
Up until now, Bootstrap 3 has shipped with Anvil by default.
Overtime the industry has moved away from bootstrap.
For new themes, like M3, having Bootstrap can be a hinderance to theming.
Unchecking this will mean that your app does not send Bootstrap to the browser.
But in existing apps, this may affect the look and feel of your app.
Legacy class names
Classnames that Anvil provides will now all be prefixed with anvil- this avoids name collisions with custom themes and css.
e.g. a Button in Anvil has a class btn this is a Bootstrapism
After turning this off the class on an Anvil Button will be anvil-btn.
Use legacy dict implementation
In Python if you have x=2 and do x.foo = "bar" this will throw an exception. AttributeError: 'int' object has no attribute 'foo'.
This is because an int in python has no __dict__ and so you can’t assign it random attributes.
If you turn this off, then native Anvil components will behave the same way. i.e. they will not have a __dict__ by default, and so doing btn = anvil.Button(), btn.foo = "bar" will throw the same sort of exception.
Root Dom Container
The app had a couple of divs before you got to the actual dom of your app.
If you inspect the page, you’ll see the difference with this one.
Some custom components (eg old versions of anvil-extras) depend on Bootstrap JS/behaviour. Some existing themes’ CSS depends on styling from the Bootstrap CSS (so they will look funny if you remove Bootstrap). Many existing themes’ CSS depends on the old Bootstrap-like names (eg class="btn" rather than class="anvil-btn").
But all of the built-in Anvil components work just fine if you turn off all the legacy options.
This is specifically about sticking random new properties onto instances of Anvil components. That has always been a bad idea – you’re supposed to use the .tag property instead – but when we first released Anvil we didn’t actually prevent you from doing that (it required features we have since added to Skulpt IIRC), so we know there are apps out there that accidentally rely on this behaviour, and we’d break them if we prevented it now. For new apps, it’s safe to prevent them from doing the bad thing
Yes, that will work, although it might be a little overkill in places. The reason it will work is that deleting your theme CSS (or at least deleting the old theme from it), removes any CSS that could depends on the old class names or on having Bootstrap loaded. It’s a bit “amputate the leg rather than setting the bone”, but it does avoid a bunch of messing around with legacy themes There’s nothing wrong with keeping built-in Anvil components around, but they’ll look a bit plain without theme styling.