title="" -> name=""
parent
f01a7e1f9d
commit
77f923baf2
|
@ -22,7 +22,7 @@ Here is an example usage of **ziba.js**:
|
|||
Notice that the text and the href are the same.
|
||||
</p>
|
||||
<p>
|
||||
Here is another one <ziba-link title="four">fource</ziba-link>
|
||||
Here is another one <ziba-link name="four">fource</ziba-link>
|
||||
This ziba tag will get turned into <a href="./four">fource</a>
|
||||
Notice that the href now has the value of the title of the ziba-link
|
||||
</p>
|
||||
|
|
6
ziba.js
6
ziba.js
|
@ -67,9 +67,9 @@ function transform_link(rootElement) {
|
|||
anchor.innerHTML = element.innerHTML
|
||||
|
||||
let ref = element.innerText
|
||||
const elementTitle = element.getAttribute("title")
|
||||
if (elementTitle) {
|
||||
ref = elementTitle
|
||||
const elementName = element.getAttribute("name")
|
||||
if (elementName) {
|
||||
ref = elementName
|
||||
}
|
||||
|
||||
const transform = element.getAttribute("transform")
|
||||
|
|
12
ziba_test.js
12
ziba_test.js
|
@ -44,26 +44,26 @@ function testTransform() {
|
|||
|
||||
|
||||
{
|
||||
html:'<ziba-link title="one">once</ziba-link>',
|
||||
html:'<ziba-link name="one">once</ziba-link>',
|
||||
expected:'<a href="./one">once</a>',
|
||||
},
|
||||
{
|
||||
html:'<ziba-link title="two">twice</ziba-link>',
|
||||
html:'<ziba-link name="two">twice</ziba-link>',
|
||||
expected:'<a href="./two">twice</a>',
|
||||
},
|
||||
{
|
||||
html:'<ziba-link title="three">thrice</ziba-link>',
|
||||
html:'<ziba-link name="three">thrice</ziba-link>',
|
||||
expected:'<a href="./three">thrice</a>',
|
||||
},
|
||||
{
|
||||
html:'<ziba-link title="four">fource</ziba-link>',
|
||||
html:'<ziba-link name="four">fource</ziba-link>',
|
||||
expected:'<a href="./four">fource</a>',
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
html:'<ziba-link title="1 2 3 4">ONCE TWICE THRICE FOURCE</ziba-link>',
|
||||
html:'<ziba-link name="1 2 3 4">ONCE TWICE THRICE FOURCE</ziba-link>',
|
||||
expected:'<a href="./1 2 3 4">ONCE TWICE THRICE FOURCE</a>',
|
||||
},
|
||||
|
||||
|
@ -285,7 +285,6 @@ function testTransform() {
|
|||
},
|
||||
]
|
||||
|
||||
|
||||
tests.forEach(function(test, testNumber){
|
||||
if (undefined === ziba.transform) {
|
||||
console.error("[test-tramsform] For test", testNumber, "ziba.transform is undefined.")
|
||||
|
@ -312,5 +311,4 @@ function testTransform() {
|
|||
|
||||
console.log("[test-tramsform] Test №", testNumber, "passed.")
|
||||
})
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue