aurelia / binding

A modern databinding library for JavaScript and HTML.
MIT License
111 stars 96 forks source link

Binding on role attribute not working in Firefox #754

Open TimVevida opened 5 years ago

TimVevida commented 5 years ago

I'm submitting a bug report

Current behavior: Binding on the role attribute of an element does not work correctly. The role attribute is completely omitted, either using role.bind or the role attribute with interpolation.

Expected/desired behavior:

Unfortunately, the Gist Run is not saving at the moment, so I will just show some sample code:

Possibly related to #486.

AsenTahchiyski commented 4 years ago

Not working in Chrome as well, so I guess not working at all.

bigopon commented 4 years ago

Thanks for notifying. Ill have a look

bigopon commented 4 years ago

I've identified the issue and created a fix demo here https://codesandbox.io/s/heuristic-leftpad-13uhl

A PR will be coming soon. For now, please do the following in your entry to temporarily fix it:

import {
  ObserverLocator,
  DOM,
  dataAttributeAccessor,
  propertyAccessor
} from 'aurelia-framework';

ObserverLocator.prototype.getAccessor = function(obj, propertyName) {
  if (obj instanceof DOM.Element) {
    if (propertyName === 'class'
      || propertyName === 'style' || propertyName === 'css'
      || propertyName === 'value' && (obj.tagName.toLowerCase() === 'input' || obj.tagName.toLowerCase() === 'select')
      || propertyName === 'checked' && obj.tagName.toLowerCase() === 'input'
      || propertyName === 'model' && obj.tagName.toLowerCase() === 'input'
      || /^xlink:.+$/.exec(propertyName)) {
      return this.getObserver(obj, propertyName);
    }
    if (/^\w+:|^data-|^aria-/.test(propertyName)
      || propertyName === 'role'
      || obj instanceof DOM.SVGElement && this.svgAnalyzer.isStandardSvgAttribute(obj.nodeName, propertyName)
      || obj.tagName.toLowerCase() === 'img' && propertyName === 'src'
      || obj.tagName.toLowerCase() === 'a' && propertyName === 'href'
    ) {
      return dataAttributeAccessor;
    }
  }
  return propertyAccessor;
}
AsenTahchiyski commented 4 years ago

Thanks bigopon, works as expected with interpolation.