Blazor Cascading Parameters don’t “just work” with lambdas or method callback

TL;DR: Blazor Cascading Parameters are matched by Type not necessarily by Name. The simplest solution is to declare the Parameter type as Delegate. If you need to distinguish more than one delegate cascading parameter, then declare a named delegate type (that's a one-liner in C#) and use that as the parameter type.

The problem

You want to pass a callback as a cascading parameter. You try passing a lambda, or possibly a method, and create a CascadingParameter property, with matching name, of type Action or Func<...> or similar, to receive it. But the cascading parameter is always set to null.

Cascading parameters are matched up by Type, not by name, and who knows what the compiled type of a lambda will be? The C# reference tells you that that lambdas can be converted to delegates or expression trees but 'can be converted to' isn't good enough for matching up by Type.

The quickest fix

Declare your parameter to be of type Delegate. Most callable things in C# are of type Delegate.

// Declaration in the child component
[CascadingParameter]public Delegate OnChange { get; set; }

// Use in the child component. The null is what DynamicInvoke requires for 'no parameters'

# In the parent container
<CascadingValue Value="StateHasChanged" >

If that's not good enough

If you must distinguish between several Delegate parameters, or just want to better express intent in your code, you can define a named delegate:

public delegate void StateHasChangedHook();

and use that as the Type of your CascadingParameter:

// Declaration in the child component
[CascadingParameter]public StateHasChangedHook OnChange { get; set; }

// Use in the child component is slightly simpler

# In the parent container
<CascadingValue Value="(StateHasChangedHook)this.StateHasChanged" >

When you use named delegates, you can invoke them with onChange() syntax instead of .Invoke() or DynamicInvoke(null).

You can inspect what was set in the child parameter

log.LogDebug("OnChange was set {OnChange}.MethodInfo={MethodInfo}",OnChange,OnChange?.GetMethodInfo())

Recall that Action<> and Func<> are themselves named delegates, not types. They are declared in the System assembly as for instance: public delegate void Action<in T>(T obj)

What are the ARIA roles & accessible names for HTML Elements?

To work with HTML elements via their ARIA attributes, you must learn a minimum about two ARIA attributes:

  1. The ARIA role
  2. The ARIA accessible name, which can and should be a human-readable piece of text such as Your Name, not an html id like your-name.

But it is said that no ARIA is better than bad ARIA! So here is your bare-minimum ‘must-know’ to work successfully with aria role and aria accessible name.

An example: aria roles and names for a small form

testing-library pushes you to target elements in your tests by aria role and name, in the hope that you are then testing what your user interface actually presents to a user. Here's a testable example of the role and accessible names for a small form which you can run from an npm project with devDependencies @jest and @testing-library:

import '@jest/globals'
import '@testing-library/jest-dom'
import {screen, fireEvent} from '@testing-library/dom'

test('Example role and accessible names', ()=>{

      const div= document.createElement('div')
      div.innerHTML=`<form data-testid='form1'>
          <legend>Form Alpha</legend>
          <label>Search : <input type='search' value="something" /></label>
          <label><input type='checkbox' /> In Stock Only</label>
          <button>The Go Button</button>


      const fieldSet= screen.getByRole('group',{name:"Form Alpha"})

      const searchBox=screen.getByRole('searchbox', {name:/Search/i})

      const checkBox=screen.getByRole('checkbox', {name:/in stock only/i})

      const form=screen.getByTestId('form1')

Now, some of these names and roles you could have guessed and some of it you couldn't. Let's take out the guesswork.

What Role and what Accessible Name do my HTML elements have?

HTML Element Roles

You can get a quick idea of roles just by looking at some of the defined ARIA roles:

  • article, banner, button, cell, checkbox, columnheader, combobox, command, comment, complementary, composite, contentinfo, definition, dialog, document, figure, form, generic, grid, gridcell, group, heading, img, input, landmark, link, list, listbox, listitem, log, main, mark, marquee, math, menu, menubar, menuitem, menuitemcheckbox, menuitemradio, meter, navigation, option, presentation, progressbar, radio, radiogroup, range, region, roletype, row, rowgroup, rowheader, scrollbar, search, searchbox, section, sectionhead, select, separator, slider, spinbutton, status, structure, suggestion, switch, tab, table, tablist, tabpanel, term, textbox, timer, toolbar, tooltip, tree, treegrid, treeitem, widget, window

Most of them split into document structure and landmark roles vs widget and composite widget roles and you can probably guess most of which html elements implicitly have which roles by default, but some you would guess wrong. The other categories of roles are Abstract, Live Region, and Window. Some of the roles form hierarchies, with sub-roles.

Here is a table of the implicit ARIA role given by default to some commonly used html elements, along with the permitted overrides.

Implicit ARIA Roles for some common HTML elements

HTML Element Implicit ARIA Role Permissible explicit Roles
nav navigation none
article article document, main, presentation &c
a href="..." link button,checkbox,menuitem &c
a without href none any
button button tab, checkbox, combobox, link, menuitem, &c
form form but only if it has an accessible name search, none or presentation
fieldset group radiogroup, presentation, none
img alt="..." img button, checkbox, link, menuitem, option, tab &c
img alt="" presentation presentation, none
input[type=button] button checkbox, combobox, link, &c
input[type=checkbox] checkbox button with aria-pressed, &c
input[type=image] button link, menuitem, radio, switch &c
input[type=number] spinbutton
input[type=radio] radio menuitemradio
input[type=range] slider
input[type=reset] button
input[type=submit] button
input[type=search] with no list attribute searchbox none
input[type=search] with list attribute combobox none
input[type=email] with no list attribute textbox none
input[type=email] with list attribute combobox none
input[type=tel] with no list attribute textbox none
input[type=tel] with list attribute combobox none
input[type=text] with no list attribute textbox combobox, searchbox, &c
input[type=text] with list attribute combobox none
input[type=url] with no list attribute textbox none
input[type=url] with list attribute combobox none
ul,ol list directory, group, listbox, menu, menubar, &c
label,legend,caption none none
main main none
menu list directory, group, listbox, menu, menubar, &c
optgroup group none
option option none
select with multiple attribute & no size greater than 1 combobox menu
select otherwise listbox none
textbox textbox none
table table any
td cell, if a descendant of a table any
th columnheader or rowheader any

You can see some patterns:

  • Many elements such as main, article, option, textbox have a fixed semantic meaning which is pretty much the same as their role. They can only have that fixed role and it can't be overridden.
  • Some elements have no implicit Aria role but can be given any explicit role. These elements include div,span,code,blockquote,most of text elements such as em,strong, &c. Only give them a role if they really will play that role! For instance if you use them as parts of a custom widget. Otherwise they are best without a role. Not everything should have a role.
  • Invisible elements such as style and script have no aria role and are not permitted an explicit role either.
  • Label, legend, caption are in a sense special elements whose aria job is to label some other element with an accessible name. They can't be given any other role.
  • Some element roles including a,img,select (and of course input) depend on how their attributes are set.
  • See the HTML element reference pages to find the full list of html elements and the full list of permitted explicit roles for those that aren't in the above table.

The table mentions what explicit roles can be given. An explicit role is given to an HTML element by giving it a role="rolename" attribute. But the advice is to only do this when you have to. Work with the native HTML roles.

HTML Element Accessible Names

An accessible name can and should be a human-readable piece of text such as 'Your Name', not an html id like your-name.

To understand what the accessible name of a component is, you must understand the accessible name computation. Here are, roughly, the first 3 steps of the accessible name computation for HTML. This is enough to get you off the ground and calculate most of your accessible names.

The Accessible Name Computation for HTML Elements

  1. The aria-labelledby property is used if present.
  2. If the name is still empty, the aria-label property is used if present.
  3. If the name is still empty, then the 3rd step depends on the element and is described in the Accessible Name Computation Section By HTML Element. Here is a summary table:
HTML Element Accessible Name Calculation if the element has no aria-label or aria-labelledby
<input type="text">, <input type="password">, <input type="number">, <input type="search">, <input type="tel">, <input type="email">, <input type="url"> and <textarea> Use the associated label element or elements accessible name(s) - if more than one label is associated; concatenate by DOM order, delimited by spaces.
If the accessible name is still empty, then: use the control's title attribute.
Use the control's placeholder value.
<input type="button">, <input type="submit"> and <input type="reset"> Accessible Name Computation Use the associated label element(s) accessible name(s) - if more than one label is associated; concatenate by DOM order, delimited by spaces.
Use the value attribute.
For input type=submit and type=reset: if the prior steps do not yield a usable text string, and the value attribute is unspecified use the implementation defined string respective to the input type.
Otherwise, if the control still has no accessible name use title attribute.
<input type="image"> Accessible Name Computation Use the associated label element(s) accessible name(s) - if more than one label is associated; concatenate by DOM order, delimited by spaces.
Use alt attribute if present and its value is not the empty string.
Use title attribute if present and its value is not the empty string.
Otherwise if the previous steps do not yield a usable text string, use the implementation defined string respective to the input type (an input in the image state represents a submit button). For instance, a localized string of the word "submit" or the words "Submit Query".
<button> Use the associated label element(s) accessible name(s) - if more than one label is associated; concatenate by DOM order, delimited by spaces.
Use the button element subtree.
Use title attribute.
<fieldset> If the accessible name is still empty, then: if the fieldset element has a child that is a legend element, then use the subtree of the first such element.
If the accessible name is still empty, then:, if the fieldset element has a title attribute, then use that attribute.
Otherwise, there is no accessible name.
<output> Use the associated label element or elements accessible name(s) - if more than one label is associated; concatenate by DOM order, delimited by spaces.
Use title attribute.
Other Form Elements Use label element.
Use title attribute.
<summary> If the first summary element, which is a direct child of the details element, has an aria-label or an aria-labelledby attribute the accessible name is to be calculated using the algorithm defined in Accessible Name and Description: Computation and API Mappings.
Use summary element subtree.
Use title attribute.
If there is no summary element as a direct child of the details element, the user agent should provide one with a subtree containing a localized string of the word "details".
If there is a summary element as a direct child of the details element, but none of the above yield a usable text string, there is no accessible name.
<figure> If the accessible name is still empty, then: if the figure element has a child that is a figcaption element, then use the subtree of the first such element.
If the accessible name is still empty, then: if the figure element has a title attribute, then use that attribute.
<img> Use alt attribute, even if its value is the empty string.
An img with an alt attribute whose value is the empty string is mapped to the presentation role. It has no accessible name.
Otherwise, if there is no alt attribute use the title attribute.
<table> if the table element has a child that is a caption element, then use the subtree of the first such element.
if the table element has a title attribute, then use that attribute.
tr, td, th Use the title attribute.
<a> Use a element subtree.
Use the title attribute.
<area> Use area element's alt attribute.
Use the title attribute.
<iframe> Use the title attribute.
The document referenced by the src of the iframe element gets its name from that document's title element, like any other document
Section and Grouping p, hr, pre, blockquote, ol, ul, li, dl, dt, dd, figure, figcaption, div, main and body, article, section, nav, aside, h1, h2, h3, h4, h5, h6, header, footer, address Use the title attribute.
Text-level Elements: abbr, b, bdi, bdo, br, cite, code, dfn, em, i, kbd, mark, q, rp, rt, ruby, s, samp, small, strong, sub and sup, time, u, var, wbr Use the title attribute.

If this step 3 seems a bit ad hoc, the underlying logic is ARIA's categorisation into roles (and therefore elements) that have

  • Name from Author, meaning that you as the content author use a <label> (or legend or caption or figcaption or alt= attribute, or similar as appropriate to the html element) to provide an explicit accessible name
  • Name from Content, meaning that the browser reads the text nodes of the element and uses that as that accessible name.
  • No name. After all, you don't want a name for every paragraph or span or div. That would be really unhelpful.

Note that multiple labels or multiple content sources are valid, and will be concatenated with spaces.

The 3 Cases of the 3rd Step of the Accessible Name Calculation:

If you learn

  • which html elements have name from content,
  • which rely on a label,
  • which should not be named

then you've got 95% of what you need. You can then choose the appropriate way to aria-name your element:

  • Naming with child content.
  • Naming form controls with the label element.
  • Naming fieldsets with the legend element.
  • Naming tables and figures with captions.
  • Naming with a string attribute via aria-label.
  • Naming by referencing content with aria-labelledby.

Overriding the default name and not using the fallback

Steps 1 and 2, using either an aria-label="This is my name" attribute, or an aria-labelledby="id-of-a-labelling-element-with-text-content" is the override mechanism.

The common fallback mechanism — which you can always avoid using— is the title attribute. Prefer using the explicit override rather than letting a title set your name.

Parting comments

  • See for an understanding of why you are naming things and how to do it well.

  • Returning to my original example, you can see that aria is opiniated. Many aria roles and naming rules are what you'd expect, but ARIA thinking is not identical to html thinking. The input elements get accessible names from their labels, but the form as a whole only gets an accessible name if you explicitly give it one, and it only gets the Aria role of form if it has an accessible name.

  • I have only discussed roles and names. ARIA also has descriptions and states and properties. For instance, you can use aria-busy=true on elements when they are loading or waiting to be populated with data.

  • See testing-library's intro example for more on using testing-library with vanilla html or major frameworks

Learning to do it well

A starting point for learning how to create good accessible sites is

Nodes-Actions-Markup : a way to work with VanillaJS in the browser

HTML + CSS + JavaScript is probably the most powerful and flexible user
interface framework ever created so it is unsurprising that people sometimes
argue against the layering of some other framework on top of it
What, after all, can a another framework add to what is already the most powerful framework you can ask for? Nothing really.

What might be achieved is to simplify. Html plus Css plus javascript is not
simple. React, Angular, Vue and others do, in the their own way, succeed in
simplifying working with Html-Css-js, at the cost of adding another learning
curve. But we cannot pretend that it possible to be expert in any of them
without a good grip of the underlying technology.

I suggest an alternative approach. Instead of a framework on top of html+css+js
all we really need is a pattern, or a way of working. Nodes-Actions-Markup is a
pattern for working with html+css+js in dynamic web pages. Although dynamic,
the real area of interest is content-driven web pages. Most of the web is
content. If you are aiming to write a desktop-app-in-a-browser, then a framework
is a good choice. If you are aiming to present content on the web, and then
enrich it, the frameworks feel like a backward step: they start by removing
all your content.

Example code:
Example small game:


You can write effective program code against html in 3 steps:

  1. Identify the Nodes in the page which code must access
  2. Identify the Actions associated with those nodes
  3. Optionally, be able to add and remove Markup from the page


Identify your nodes of interest in the obvious way. For instance for a noughts
and crosses game (aka tic-tac-toe), you likely want to identify the entire game board
and also each of the nine squares:

const gameboardNodeId = "gameboard"
const gameboardNode = ()=> document.getElementById(gameboardNodeId)

const gameSquaresSelector = "div[role=gridcell]"
const gameSquaresNodes = ()=> gameboardNode().querySelectorAll(gameSquaresSelector)

( You might decide there is no need to use functions as I have done here, you can simply use constants:

const gameboardNodeId = "gameboard"
const gameboardNode = document.getElementById(gameboardNodeId)

One trade-off is whether you can test those 2 lines of code in a command-line test runner. The document probably won't be set up when the module defining the const is loaded. The second trade-off is that dynamically-placed nodes may still need a function call to evaluate, so perhaps the developer experience is easier if you just make everything a function call. If performance is an issue, you can memo-ise).

In a line-of-business application with form elements, the nodes you identify will be every element you wish to interact with programmatically, for instance:

const signUpFormSelector ="[role=form].signup"
const signUpFormNode = () => document.querySelector(signUpFormSelector)
const areasOfInterestSelector = ".areas-of-interest input[type=radio]"
const areasOfInterestNodes = () => signUpFormNode.querySelectorAll(areasOfInterestSelector)

How you organise and encapsulate the nodes is your key design decision, but this decision is key whatever framework or not you use for your UI. For a singleton form I might do this:

const signUpForm = {
    nodes: {
        form : signUpFormNode
        areasOfInterestNodes : areasOfInterestNodes,

but for multiple instances of a UI element appearing on a single page, I would use a constructor function with some identifier as parameter:

const allGameboardsNodeId = "all-gameboards"
const gameboardNode = (n)=> document.getElementById(allGameboardsNodeId).querySelector(`:nth-child(${n})`)
const gameSquaresNodes = (n)=> gameboardNode(n).querySelectorAll(gameSquaresSelector)

function NoughtAndCrossesBoard(boardNumber){
    this.nodes: {
        gameSquares : () => gameSquaresNodes(boardNumber)

or if you prefer ES6 class notation over js constructor functions:

class NoughtAndCrossesBoard {
        this.nodes= {
            gameSquares : () => gameSquaresNodes(boardNumber)


Actions typically depend on Nodes which they are connected to and/or must know about; and on a model which they may update. We'll discuss models more below, when we think about how Nodes-Actions-Markup relates to MVC.

Actions are of two kinds. Event listeners commonly need one-time wire-up and then they work for the lifetime of your page because the browser makes them work. For a singleton UI element with only event listeners, a method call during page load can handle all the wire-up.

    const board= new NoughtAndCrossesBoard()
    for(let i=0; i < 9; i++ ){
        const node=board.nodes.gameSquares[i]
        node.addEventListener('click', function(e){
            const whoPlayed=noughtsAndCrossesGameModel.playAt(i)
   = whoPlayed

A second kind of action is something that you might programmatically call after page load. This kind of action becomes more important as your UI grows to the point that you must construct it as multiple independent elements which may talk to each other, or if non-UI events can trigger UI changes. So this kind of action should be encapsulated together with its nodes:

function NoughtAndCrossesBoard(boardNumber, noughtsAndCrossesGameModel){
    const gameSquares = () => gameSquaresNodes(boardNumber)
    this.nodes = {
        gameSquares: gameSquares
    // This action can be called from an event listener attached to a 'New Game' button external to this board.
    this.clearBoard = function(){
        for(let square of gameSquares){
            square.innerHTML= unplayedSquareHTML
    // These actions are the one-time setup for event listeners
    for(let i=0; i < 9; i++ ){
        const node=gameSquares[i]
        node.addEventListener('click', function(e){
            const whoPlayed=noughtsAndCrossesGameModel.playAt(i)
   = whoPlayed
const unplayedSquareHTML=' '

As in all software, as the project grows you must plan what actions each element will expose to other elements, and how they are coupled, and how they get references to each other. Javascript modules with their import & export commands work well for modularisation, encapsulation, and defining which modules depend on knowledge of other modules. Modern browsers can use modules straight from markup:

<script src="js/NodesAndActions-game-board.js" type="module"></script>


If all your markup is static, you are done. You have Nodes, Actions and Markup working together. If some of your markup is dynamic, it must be placed in the page before Nodes and Actions can reference it.

    const container= allGameboardsNode()
    const games= []
    const boards= []
    for(let i=0; i < 9; i++){
        insertGameBoardMarkup(i, container)
        games.push( new NoughtsAndCrossesGameModel() )
        board.push( new NoughtAndCrossesBoard(i, game[i]) )

The code to insert markup can be done in a couple of ways. Backticks let you write markup in multiline strings in a function:

function insertGameBoardMarkup(boardNumber, container){

  const templatedContent= `<section class="oxo-board-section">
      <div role="grid" class="oxo-board" aria-label="Board 0" id="board0">
        <div role="gridcell" id="board0-cell-1" aria-labelledby="board0 board0-cell-1">
          <label>top left</label> </div>
        <div role="gridcell" id="board0-cell-2"  aria-labelledby="board0 board0-cell-2">
          <label>top middle</label> </div>
        <div role="gridcell" id="board0-cell-3"  aria-labelledby="board0 board0-cell-3">
          <label>top right</label> </div>
        <div role="gridcell" id="board0-cell-4" aria-labelledby="board0 board0-cell-4">
          <label>middle left</label> </div>
        <div role="gridcell" id="board0-cell-5"  aria-labelledby="board0 board0-cell-5">
          <label>middle square</label> </div>
        <div role="gridcell" id="board0-cell-6"  aria-labelledby="board0 board0-cell-6">
          <label>middle right</label> </div>
        <div role="gridcell" id="board0-cell-7" aria-labelledby="board0 board0-cell-7">
          <label>bottom left</label> </div>
        <div role="gridcell" id="board0-cell-8"  aria-labelledby="board0 board0-cell-8">
          <label>bottom middle</label> </div>
        <div role="gridcell" id="board0-cell-9"  aria-labelledby="board0 board0-cell-9">
          <label>bottom right</label> </div>
          .replaceAll('board0','board' + boardNumber)
          .replaceAll('Board 0','Board ' + boardNumber)
          .replaceAll('board 0','cells ' + boardNumber)

  container.insertAdjacentHTML("beforeend", `<section class="oxo-board-section">${templatedContent}</section>`)
  return container

Or you can store template markup in html template elements. With html templates you still have to do your own injection of instance-specific markup:

const gameboardTemplateId="gameboard-template"

export function insertGameBoardMarkup(boardNumber, container){
  const template=document.getElementById(gameboardTemplateId)

  const templatedContent= template.content.firstElementChild.innerHTML
          .replaceAll('board0','board' + boardNumber)
          .replaceAll('Board 0','Board ' + boardNumber)
          .replaceAll('board 0','cells ' + boardNumber)

  container.insertAdjacentHTML("beforeend", `<section class="oxo-board-section">${templatedContent}</section>`)
  return container

Or, you can get to grips with Web Components. That requires a little more learning to get off the ground though.


You can work effectively with html+javascript by organising your code as Nodes, which identify the key Html nodes of interest to your code, and Actions, which know about Nodes and also know about the models that your web page exposes to the user.

Nodes-Action-Markup vs Model View Controller

To understand model view controller and how it is a correct way to do a user interface you must understand it at two levels. At the top level, you must understand that the goal of MVC is to support the user-illusion that as the user uses your program they are dealing, not with pixels or HTML or such like, but with “real things” that they can think about and understand. For instance a signup form, or a table top game.

So the model is a key element for any interesting application and
Nodes-Actions-Markup relies on having models to do anything meaningful. A noughts-and-crosses game should have a game model to track game state: who's turn it is, whether the game has been won, what squares have been played. An html form is a special case. With forms, the browser itself knows about and maintains the model for you, so there is probably no need to add any kind of model class in code to represent it.

The view and the controller are how the user interacts with the model. The view and controller should be designed to sustain the user-illusion that the user “reaches through” the interface to manipulate and view the model.

Views have the responsibility of representing the model to the user, usually on-screen, in such a way that the user feels they are seeing the very thing itself. For instance, when a user sees an html signup form, they do not think “I can see the html elements on screen, but where's the form?” They think that the html elements in their browser is the form. And so they fill it in. (As developers, we are also tricked by this illusion bceause the HTML standard uses 'form' for the name of an HTML element! HTML sustains the illusion so successfully that you may have to pause for a moment to realise that an HTML form element is not what a human being thinks a form is). Similarly if the user see a grid of nine squares, they think that is the game.

The controller's responsibility depends on what version of MVC you are using. In some versions, the view is also responsible for letting the user update the model, as well as seeing the model. This pattern works well if you implement two-way data-binding: the view is bound to the model and changing one changes the other. In other versions, the controller is responsible for updating the model, and the view only reads it. This works well with a one-way dataflow approach. Whether you treat Actions as part of the controller or part of the view depends on your approach to MVC.

So Nodes-Actions-Markup helps you to build views and optionally controllers. The View that the user sees is the visible markup. The Nodes part of Nodes-Actions-Markup lets you read and write that view in code. The Actions part lets the user update the model, and lets your code keep the view in sync with the model.

What about the Observer pattern? Implementing the observer pattern in Javascript is not hard, but it's worth knowing that it is not essential to the goal of MVC. Rather, the observer pattern is of most use when you have multiple views on screen simultaneously, in which registering the views as observers of the model is a good way to guarantee they stay in sync.


In retrospect, one of the things that frameworks on top of HTML each offer us, is a way to organise how we work with HTML. You don't need a framework to organise how you work. A standard way of working will do.

The Argument For Machine Consciousness

The modern argument for machine consciousness can be paraphrased as follows:

  1. We know lots about how electro-mechanical systems work.


  1. Let us believe that consciousness is also an electro-mechanical system (because if it is, then we will be able to understand it).


  1. Machines can be conscious

One can sympathise with giving belief (2) a research budget. But to confidently assert that conceivable consequences of (2) – such as (3) – are facts about the world, is bluster. Writing bluster into our legal and moral thinking would be a mistake.

I suppose the motivation for (2) is, we always want to believe we can understand things. And, impatiently, we also want to believe things can be understood well enough just with the current state of our knowledge, insights and tools.

But gung-ho optimism based on unevidenced confidence does not have a good record and can do more harm than good.

At the current time, the negative I hope we can avoid is:

Large corporations will use stories about machine consciousness and machine legal status to transfer legal risk away from themselves, making it easier for them to prioritise profitable machinery over human lives.

A example will be when a corporation denies legal liability for a robot or self-driving car which injures a passer-by, by saying it was the robot's fault, not theirs.

A better, more logical, move in the early 21st century would be to first acknowledge that

  1. The current state of our knowledge, tools and insights does not suffice to understand what consciousness is or how it works.