santosh500 / jsdoc-toolkit

Automatically exported from code.google.com/p/jsdoc-toolkit
0 stars 0 forks source link

Better app/frame/Link.js #339

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I think that the original Link object is not nice.
For example, you want to add id attribute to Link.
Maybe you write a code such as above.

<pre>
function addIdToLink (link, id) {
  return link.toString().replace(/<a /i, '<a id="' + id + '"');
}
</pre>

After few minutes, you want to add class attribute to Link.
Then, do you write a code too?
I don't want to write the code.

So, I implemented Link.setAttribute method.
You can add attributes to Link using method chains.

Sample code:
<pre>
new Link().toSymbol('foo.bar').setAttribute('id', 'foobar');
// also
new Link().toSymbol('foo.bar').setAttributes({'id', 'foobar', 'class': 
'foo-bar'});
</pre>

What do you have in mind?

Original issue reported on code.google.com by yaman...@gmail.com on 20 May 2012 at 7:00

Attachments: