def mutate_dict(d, ev):
    """ Function to mutate an dict property in-place.
    Used by Component. The ``ev`` must be a dict with elements:

    * mutation: 'set', 'insert', 'remove' or 'replace'.
    * objects: the dict to set/insert/replace, or a list if keys to remove.
    * index: not used.
    """
    mutation = ev['mutation']
    objects = ev['objects']
    if mutation == 'set':
        d.clear()
    elif mutation in ('set', 'insert', 'replace'):
        assert isinstance(objects, dict)
        for key, val in objects.items():
            d[key] = val
    elif mutation == 'remove':
        assert isinstance(objects, (tuple, list))
        for key in objects:
            d.pop(key)
    else:
        raise NotImplementedError(mutation)
