Skip to content

Releases: canjs/can-migrate

can-route codemods handle more cases

15 Mar 15:08
Compare
Choose a tag to compare

#94

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

09 Mar 21:56
Compare
Choose a tag to compare

fixing value->default codemod for named DefineMaps

09 Mar 20:29
Compare
Choose a tag to compare

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

09 Mar 18:55
Compare
Choose a tag to compare

#88

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

09 Mar 15:33
Compare
Choose a tag to compare

not running attr-from codemod on attributes that are already bindings

09 Mar 13:54
Compare
Choose a tag to compare

Fixing value->default false positives

09 Mar 03:53
Compare
Choose a tag to compare

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
  }
});

#85

Another fix for attr-from false positives

07 Mar 23:32
Compare
Choose a tag to compare

Fixes false positives in attr-from codemod

07 Mar 00:00
Compare
Choose a tag to compare

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

25 Jan 23:40
Compare
Choose a tag to compare

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.