Releases: canjs/can-migrate
can-route codemods handle more cases
The can-route
codemods for version 4 now handle a lot more use cases.
The register
transform will change any calls to the identifier for the default import of "can-route"
to call .register
. This handles canRoute
in the example below or anything else that you name this import:
import canRoute from "can-route";
canRoute.register("{page}");
The ready
transform will similarly look for the default import of "can-route"
and any calls to that identifiers ready
function and change it to start. This handles route.ready
in the example below or anything else that you name this import:
import route from "can-route";
route.start();
The page
transform has been renamed to template
and will change any template properties using colons (like :page
) and change them to using braces ({page}
) in the first argument of route(...)
or route.register(...)
(or anything else you name the default import of "can-route"
.
import myRouter from "can-route";
myRouter.register("{foo}/{bar}", { foo: "abc" });
not writing files that have not changed
fixing value->default codemod for named DefineMaps
This fixes the value
-> default
conversion for DefineMaps that are named like:
let ViewModelTwo = DefineMap.extend("NamedDefineMap", {
myProp: {
value: 'something'
},
myOtherProp: {
set(value) {
return value;
}
},
myFunc(el) {
return el.value
},
myFunc2(el) {
return {
value: el.value
};
}
});
fixing attr-from again so that is does not throw when attributes are out of sync
This fixes things like
<ul class="nav navbar-nav">
<li class="{{#routeCurrent page='home'}}active{{/routeCurrent}}"><a href="{{routeUrl page='home'}}" on:click="closeMenu()">Home{{#routeCurrent page='home'}} <span class="sr-only">(current)</span>{{/routeCurrent}}</a></li>
</ul>
Previously, the Home{{#routeCurrent page='home'}}
was treated like an attribute and causes an error.
Fixing attr-from codemod changing incorrect attribute due to booleans
not running attr-from codemod on attributes that are already bindings
Fixing value->default false positives
This makes sure value is only changed to default if it is a key
directly on a PropDefinition passed to DefineMap.extend.
var VM = DefineMap.extend({
prop: {
value: "hello" // `value` should be changed to `default`
},
myOtherProp: {
set(value) { // `value` should not be changed here
return value; // `value` should not be changed here
}
},
myFunc(el) {
return el.value // `value` should not be changed here
}
});
Another fix for attr-from false positives
Fixes false positives in attr-from codemod
This change restricts the attr-from codemod to attributes:
- on custom elements
- that don't start with can-
- that are not aria- or data- attributes
- and are in the globalAttributes list
This means these will not be modified:
<can-import from="some/thing"/>
<script src="{{joinBase 'steal.production.js'}}"></script>
Published v0.0.6 as v1.0.0
Version 1.0.0 will be the basis for the can-migrate
CanJS 2 to 3 transforms.
Beyond this we will have a version flag to be used for different migrations.