GoogleChrome / accessibility-developer-tools

This is a library of accessibility-related testing and utility code.
Apache License 2.0
2.28k stars 363 forks source link

Update `composedParentNode` for Shadow DOM v1. #311

Closed bicknellr closed 7 years ago

bicknellr commented 8 years ago

This PR updates axs.dom.composedParentNode to use assignedSlot (new in Shadow DOM v1, link) if available and doesn't attempt to call getDestinationInsertionPoints (removed) if it isn't available.

Some of the tests specifically check the behavior of content elements with a set select attribute; I changed these to use slots with name attributes and added slot attributes to the relevant nodes outside the shadow tree to get the same 'distributed vs. not distributed' behavior. It might be worth renaming the tests since they're not about content elements anymore.

(fixes #312)

bicknellr commented 8 years ago

After cleaning, it looks like this causes a closure compiler warning about assignedSlot never being defined on Node. Maybe I should try to get Shadow DOM v1 stuff into closure first? :/

alice commented 7 years ago

Sorry for not looking at this sooner!

You can patch around this locally by adding the following in externs.js:

/**
 * @constructor
 * @extends {HTMLElement}
 */
function HTMLSlotElement() {}

/**
 * @return {?HTMLSlotElement}
 */
HTMLElement.prototype.assignedSlot = function() {};

And you might want to make a PR on https://github.com/google/closure-compiler/blob/master/externs/browser/html5.js to add the same lines where appropriate.

alice commented 7 years ago

(Meanwhile, https://github.com/GoogleChrome/accessibility-developer-tools/pull/327 updates us to use the google-released closure compiler which should stay more up to date)

bicknellr commented 7 years ago

Updated with your patch - no more closure errors!

bicknellr commented 7 years ago

Oh, I still need to check for the right node types...

bicknellr commented 7 years ago

No problem!