gulp-version-number icon indicating copy to clipboard operation
gulp-version-number copied to clipboard

Add support for ng-href and on<events> in link tag

Open lawmercado opened this issue 6 years ago • 6 comments

I found out that:

<link ng-href="themes/{{theme||'default'}}/css/style.css" rel="stylesheet" onerror="this.href='themes/experter/css/style.css'">

is being parsed as:

<link ng-href="themes/{{theme||?v=44edd1b317271634126140a94694357b'default'}}/css/style.css" rel="stylesheet" onerror="this.href='themes/experter/css/style.css'">

which is not the expected output. The expected output should be:

<link ng-href="themes/{{theme||'default'}}/css/style.css?v=44edd1b317271634126140a94694357b" rel="stylesheet" onerror="this.href='themes/default/css/style.css?v=44edd1b317271634126140a94694357b''">

I'm using version 0.1.7, using the version config as shown below:

const versionConfig = {
    'value': '%MDS%',
    'append': {
        'key': 'v',
        'to': ['js', 'css', 'sass'],
    },
};

lawmercado avatar Oct 11 '18 22:10 lawmercado

now, custom attribute supported. "append.to.{Object}.attr"

shinate avatar Oct 12 '18 10:10 shinate

Nice. But this does not solves the problem related to ng-href , right?

lawmercado avatar Oct 15 '18 12:10 lawmercado

attribute is ['href', 'ng-href', ...] which you want to append

shinate avatar Oct 17 '18 06:10 shinate

Both of these attributes. As I understand, using

const versionConfig = {
    'value': '%MDS%',
    'append': {
        'key': 'v',
        'to': [
            {
                'type': 'js'
            },
            {
                'type': 'css',
                'attr': ['href', 'ng-href', 'onerror']
            }
        ],
    },
};

Is giving me this output

<link ng-href="themes/{{theme|| ?v=2b0b76da590ce4487593d2b93d10295c'default}}/css/style.css" rel="stylesheet" onerror="this.href=?v=2b0b76da590ce4487593d2b93d10295c'themes/default/css/style.css'">

Which is not right. I'm defining versionConfig wrong?

lawmercado avatar Oct 17 '18 13:10 lawmercado

I think that's not a standard link 😆, it contains templates or logic. Why not use the replacement mode

shinate avatar Oct 18 '18 01:10 shinate

I see. Even if is not a standard link, the regex used do match links should be able to deal with this (since is a valid syntax).

And did you notice that the generated onerror's attribute link is wrong too?

lawmercado avatar Oct 18 '18 19:10 lawmercado