- From: Matthew Phillips <matthew@bitovi.com>
- Date: Fri, 22 May 2015 10:30:26 -0400
- To: Philip Jägenstedt <philipj@opera.com>
- Cc: public-html <public-html@w3.org>
- Message-ID: <CAHm1x+a6E1ysSBUAefFoegFh+utwJhxa0VMq4B=LoVZUnWuB_A@mail.gmail.com>
Thanks Philip. setAttribute can't be used in my scenario because it doesn't accept some characters, this will throw: el.setAttribute("[foo]", "bar") As not being a valid attribute name. However innerHTML will accept these types of attribute names just fine. These special attribute names are started to be adopted by frameworks for data-binding (Angular 2 is doing something like this I believe). Maybe we should adjust what is a valid attribute name? For now I think your workaround might work, I'll give it a try. On Fri, May 22, 2015 at 8:14 AM, Philip Jägenstedt <philipj@opera.com> wrote: > On Thu, May 21, 2015 at 8:01 PM, Matthew Phillips <matthew@bitovi.com> > wrote: > > I just came across a warning for using a deprecated Attr method: > > > > > https://developer.mozilla.org/en-US/docs/Web/API/Attr#Deprecated_properties_and_methods > > > > I'm using cloneNode() which is on the list. What is the workaround? Will > I > > be able to do Node.prototype.cloneNode.call(attr) instead? > > Hi Matthew, > > This is related to a simplification of Attr that, if successful, would > result in Attr no longer inheriting from Node: > https://dom.spec.whatwg.org/#interface-attr > > If that happens, Node.prototype.cloneNode.call(attr) wouldn't work > either, because attr would no longer be a Node, so it would throw an > exception. > > Your best bet is to avoid Attr entirely, using getAttribute() and > setAttribute() instead. However, if for some reason you have an Attr > and want to set the same attribute on another element, > element2.setAttributeNS(attr.namespaceURI, attr.name, attr.value) > should do the trick. > > Philip (does not work on Gecko, but pokes at Attr in Blink) > -- Bitovi Development | Design | Training | Open Source
Received on Friday, 22 May 2015 14:30:59 UTC