dojo / framework

Dojo Framework. A Progressive Framework for Modern Web Apps
https://dojo.io/
Other
585 stars 78 forks source link

Add remove node operation to assertion template #315

Closed aciccarello closed 5 years ago

aciccarello commented 5 years ago

Enhancement Add a method to assertion templates to allow removing an element using a selector. This currently requires replacing the children of the parent element and filtering out the children.

Package Version: @dojo/framework@^5.0.0

Code

const baseTemplate = assertionTemplate(() => v('div', { key: 'wrapper' } [
  v('div', { key: 'first' }, ['Content']),
  v('div', { key: 'second' }, ['Content']),
  v('div', { key: 'third' }, ['Content']),
  v('div', { key: 'fourth' }, ['Content']),
]));

Expected behavior:

baseTemplate.remove('@second')

Would return the assertion template without the node with key

Actual behavior:

baseTemplate.replace('@wrapper', [
  v('div', { key: 'first' }, ['Content']),
  v('div', { key: 'third' }, ['Content']),
  v('div', { key: 'fourth' }, ['Content']),
]);

Currently you need to replace all the children to remove one.

Would be closed by #314

aciccarello commented 5 years ago

Closed by #412