Is there a way to pre-compute a polymer element based on a condition ? Let's say for every button, there is an admin button that opens a popup that has debug features. As the user will not dynamically become an admin, I'd like to pre-compile my polymer element to avoid the overhead of computing whether it should be displayed every time I insert a button.
It would probably look like
<dom-module id="a-very-common-button">
<template>
<div>
<!-- Remove the button before it is inserted everywhere -->
<button keep-if="window.isAdmin">
button for admins
</button>
<button>regular button</button>
</div>
</template>
</dom-module>
Is it possible ?
Just to make sure you understand the implications - you realise that this is all in the client, putting admin content in there would be a severe security issue as anyone could set window.isAdmin=true.
Apart from that you could extend the native button element providing this function for every standard button. https://www.polymer-project.org/1.0/docs/devguide/registering-elements#type-extension
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.