Re: Making all elements and attributes that contain hyphens valid

Silvia Pfeiffer, Tue, 22 Oct 2013 12:20:23 +1100:
> On Tue, Oct 22, 2013 at 8:53 AM, Jirka Kosek <jirka@kosek.cz> wrote:
>> On 21.10.2013 22:37, Sam Ruby wrote:
>>>> 1. data-* attributes should be encouraged for inpage scripts and
>>>> Javascript libraries who are not yet widely recognized
>>> 
>>> What would you expect to happen once such a library becomes widely
>>> recognized?
>> 
>> Library authors can decide to switch to prefix-* or support both
>> syntaxes. AFAIK AngularJS supports both ng-* and data-ng-*.
> 
> Interesting that you dug into this. AngularJS actually supports a
> variety of extension solutions:
> http://docs.angularjs.org/guide/directive

> 
> They also support x-ng-* , ng:* , ng_* - I hope that we're not
> expecting every single library to support all these prefix variations
> just to "secure and cover" their namespace.

One reason they “cover” data-ng-* and x-ng-* is validity: ”the 
directive can be prefixed with x-, or data- to make it HTML validator 
compliant”. (Except that x- is not HTML validator compliant -it is only 
recognized by the spec.) 

So, presumably, if HTML5 - and the validator - was as welcoming with 
regard to ng-* as it is for data-ng-*, they would not have hijacked 
data-ng-* (and x-ng-*).

But then again, they also have a “conditional comment directive” (<!-- 
directive: my-dir exp -->), and class names, too. So flexibility 
(including w.r.t legacy browsers), is also part of the motivation - 
hence, making the validator silent with regard to ng-*, would probably 
not solve everything.

But of course: If HTML5 had not minted data-* and x-*, AngularJS 
probably would not have minted them either.
-- 
leif halvard silli

Received on Tuesday, 22 October 2013 03:24:49 UTC