Giter Site home page Giter Site logo

Comments (5)

aaronshaf avatar aaronshaf commented on July 30, 2024

This bit me today with SVG's viewBox :-(

from custom-elements.

aaronshaf avatar aaronshaf commented on July 30, 2024

This basically makes SVG unusable in some browsers in custom elements.

from custom-elements.

chiefcll avatar chiefcll commented on July 30, 2024

I was looking into this as well - I don't see why setAttribute is being patched as the mutation observer is handling the changing of attributes.

Seems like this can be fixed by removing:

const _nativeSetAttribute = Element.prototype.setAttribute;
Element.prototype['setAttribute'] = function(name, value) {
changeAttribute(this, name, value, _nativeSetAttribute);
};
const _nativeRemoveAttribute = Element.prototype.removeAttribute;
Element.prototype['removeAttribute'] = function(name) {
changeAttribute(this, name, null, _nativeRemoveAttribute);
};
function changeAttribute(element, name, value, operation) {
name = name.toLowerCase();
const oldValue = element.getAttribute(name);
operation.call(element, name, value);
// Bail if this wasn't a fully upgraded custom element
if (element[_upgradedProp] == true) {
const definition = _customElements()._definitions.get(element.localName);
const observedAttributes = definition.observedAttributes;
const attributeChangedCallback = definition.attributeChangedCallback;
if (attributeChangedCallback && observedAttributes.indexOf(name) >= 0) {
const newValue = element.getAttribute(name);
if (newValue !== oldValue) {
attributeChangedCallback.call(element, name, oldValue, newValue, null);
}
}
}
}

I have and everything still works in FF + Safari 10 - need to check IE11

from custom-elements.

bicknellr avatar bicknellr commented on July 30, 2024

This should be fixed (v1.0.0-alpha.4): http://jsbin.com/yayibu/edit?html,output

from custom-elements.

bicknellr avatar bicknellr commented on July 30, 2024

BTW, this is were the new patches to attribute methods of the Element prototype start:

Utilities.setPropertyUnchecked(Element.prototype, 'setAttribute',

from custom-elements.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.