You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
No check of overwriting id attribute for dynamic snippets #242
When I set up my own id attribute on an HTML element which also holds n:snippet attribute with dynamic name ('snippet-post' . $post->id), it turns up that a check which is implemented for static snippets is not triggered in case of dynamic ones.
That leads to obscure situations when rerendering of snippets suddenly stops working and you wonder how it is possible when you just added id attribute to HTML (!) and do not know under-the-hood of snippets.
Steps To Reproduce
Use this code and see that the date is not changing when hitting the button:
Actually using id attribute to handle snippet is not clean/semantic solution. id attribute is too generic and can be used by anyone with access to DOM so it should be frontendist's privilege to decide what it will be used for and how and backend should not/must not force its own usage. I understand that it came from time of HTML 4, but it should be reconsidered now.
I suggest to take advantage of data-* attribute and set up custom attribute something like data-nette-snippetId which is sure enough not to be collided with anyone else's interest.
I know this is a very complicated way, but there must first be some discussion of how to change it in order to not disrupt the function of components that rely on the original attribute name.
Activity
BlockMacros: check when dynamic snippet is combined with id attribute […
BlockMacros: added $snippetAttribute for custom HTML attribute with s…
BlockMacros: check when dynamic snippet is combined with id attribute […
dg commentedon Jan 3, 2020
Fixed.
You can change snippet's HTML attribute this way:
I know this is a very complicated way, but there must first be some discussion of how to change it in order to not disrupt the function of components that rely on the original attribute name.
dakur commentedon Jan 6, 2020
😮 That's crazy, but I understand. Thank you for the fix anyway!
[latte] BlockMacros: added $snippetAttribute for custom HTML attribut…
[latte] BlockMacros: check when dynamic snippet is combined with id a…