Marko: `...attr` which replaces now deprecated `${attr}` breaks class Array syntax

Created on 27 Feb 2018  路  6Comments  路  Source: marko-js/marko

Bug Report

Marko Version: 4.8.0

Details


The current version of Marko gives me the following warning in the console: ${attrs} is deprecated, use ...attrs instead

However when I refactored my component to use ...attrs it broke the class=['class1', 'class2'] syntax for the element I was spreading attributes into.

Example

Simple input component:

$ const extraAttrs = input['*'] || {};

<input class=['form-control', input.error && 'form-control-error']
  name=input.name type="text" ...extraAttrs/>

In template:

<simple-input name="full-name" error=false maxlength=5/>

Expected Behavior


Should render:

<input class="form-control" name="full-name" type="text" maxlength="5"/>

Actual Behavior


Renders:

<input class="[&quot;form-control&quot;,null]" name="full-name" type="text" maxlength="5"/>

class Array is JSON stringified.

Additional Info

Your Environment

  • Firefox developer edition 59
  • macOS High Sierra 10.13.3
  • node v9.5.0
bug

Most helpful comment

Same issue with lasso
WARNING!! ${attrs} is deprecated, use ...attrs instead at node_modules/lasso/head-118-3-26-33519-xjraht.l20k.marko:1:0

All 6 comments

Hey @gunjam. Thanks for reporting this issue. Someone will take a look at this soon. In the meantime, you can still use ${attrs} even though it's labeled as deprecated.

Ta!

@austinkelleher hey austin, this exact error is also popping up in the lasso-cli tool while in watch mode - see below:

screenshot from 2018-04-12 15-26-22

Same issue with lasso
WARNING!! ${attrs} is deprecated, use ...attrs instead at node_modules/lasso/head-118-3-26-33519-xjraht.l20k.marko:1:0

@austinkelleher Hey Austin, any news on this issue? The same warning we got in markojs 4.9.0 and 4.10.0.

Fixed in 4.11

Was this page helpful?
0 / 5 - 0 ratings