What is the difference between Polymer's light DOM and local DOM?
From the docs(1):
The DOM that an element creates and manages is called its local DOM.
This is distinct from the element's children which are sometimes called its light DOM for clarity.
This doesn't seem to help much. Isn't the light DOM supposed to contain the children and if so what does the local DOM contain?
[1] https://www.polymer-project.org/1.0/docs/devguide/local-dom
Here's an example to explain the difference. Suppose you have the following custom element:
<dom-module id="x-foo">
<template>
<div>I am local dom</div>
<content></content>
</template>
<script>
Polymer({
is: 'x-foo'
});
</script>
</dom-module>
And you use it like this in your document:
<x-foo>I am light dom</x-foo>
What ever you put into the template of the element is local dom. What you put as children to your custom element when you use it is light dom. So, the local dom is determined by the creator of the element, while the light dom is set by the user of the element. Of course, when you both create and use your own custom elements you have some flexibility what to put where.
If you create a component <a-component>, then it has its own markup (it's template) which is the local DOM. The template can contain <content></content> tags (one unnamed and multiple named ones) where children are projected to. Content added as children is shown in the light DOM.
When we have an <a-component> with it's local DOM
<dom-module id="a-component">
<template>
<div>A</div>
<content></content>
<div>B</div>
</template>
</dom-module>
and we use it like
<a-component>
<div>C</div>
</a-component>
then <div>C</div> is shown in the light DOM. The resulting DOM in the browser then looks like
<div>A</div>
<div>C</div>
<div>B</div>
Where <div>A</div> and <div>B</div> are called the local DOM when seen from within <a-component> and shady or shadow DOM when seen from the outside of the component and <div>C</div> is in the light DOM.
If we take again this markup we would add to the page
<a-component>
<div>C</div>
</a-component>
You see that <div>C</div> is directly added by the user of the component while <div>A</div> and <div>B</div> are hidden (in the shadow) and revealed only later when <a-component> is processed by the browser.
The distinction of shady and shadow is about if full shadow DOM is enabled or not for Polymer. Shady emulates shadow to some degree but with some notable differences, this is why it got a different name.
Related
In Chrome DevTools, the element tab shows the constructed DOM and I can click on elements in the DOM which also highlights the element on the page. Image of both versions shown in DevTools
If the DOM shows:
<input class="gLFyf">
Then the page highlight will show:
input.gLFyF
I realise these are two ways of writing the same thing, I also realise the former is HTML style and the latter follows CSS conventions. However, I lack the vocabulary to properly refer to either.
What do I call each format?
Eg. would it make sense to refer to <input class="gLFyf"> as HTML syntax and input.gLFyF as CSS syntax? Is there a more widely accepted way to differentiate and name them?
gLFyf is the name of the class which is an attribute that can be referred to in the stylesheet to match styles with elements of that class on the page.
A class leads with a period (.) - whereas an ID would lead with a hash (#).
So .gLFyf is a class.
And #gLFyf would be an ID.
It is a class, whether viewing HTML markup or the DOM inspector. They both refer to the same thing as you already state.
This may be of some use/reference.
I'm fairly new to typo3 and I have an issue that i don't find an explanation on how to change it. I'm sure there are already some helpful tutorials but i have issues finding them.
I am making a website and I have already made a template for fontend and backend.
It is a very simple test template that consists only of one slider and one text element.
The slider is handmade and should have the following layout:
<section class="custom-slider">
<img src="img1.jpg">
<img src="img2.jpg">
...
</section>
Thought easy, i have my slider place in my template, just need to add plain images.
but typo3 gives me:
<section class="custom-slider">
<div id="c3" class="frame frame-default frame-type-image frame-layout-0"><header><h2 class=""></h2></header><div class="ce-image ce-center ce-above"><div class="ce-gallery" data-ce-columns="1" data-ce-images="1"><div class="ce-outer"><div class="ce-inner"><div class="ce-row"><div class="ce-column"><figure class="image"><img class="image-embed-item" src="fileadmin/_processed_/1/2/csm_slider1_c3fdcdcaf5.jpg" width="600" height="187" alt="" /></figure></div></div></div></div></div></div></div>
</section>
Now i search how i can make my own custom elements or render existing elements different. I have found a lot of tutorials but they all are based on 'Extension Builder' or 'Builder' and require a custom extention. These don't seem to work on Typo3 8.7.x. Is there a different solution or can someone give me a good tutorial link?
Thank you in advanst:)
Ps: since i will have the same problem with styled text elements i would like to ask if there is a way to declare in the themplate how different predeterment elements are rendered?
In TYPO3 8.7 (I assume) your rendering is done with FSC (fluid_styled_content), so you have to understand the mechanism of FSC to render a CE (ContentElement).
As the name suggests Fluid is used. Fluid uses different templates organized in three categories (each with it's own folder):
Layouts
Templates
Partials
The call goes to a template (in the folder 'templates') where a tag can be inserted to use a specific layout (from floder 'Layouts'). if this tag is given the rendering starts with the given layout. In the layout different sections and partials can be called. Sections belong to the template, partials need to have an own partial file (in folder 'Partials').
You can override single files from the given declaration to individulize the behaviour.
In your example you may evaluate the field layout in layout, template and partial to avoid the default wrapping of any content (your images) in different div tags.
I have an HTML where inline element span which hold block element example div. I have pasted below HTML source in the source view of TinyMCE and press Ok
<span>plain text<div>test div</div></span>
Further, I have click on the source view and HTML it changes to the below HTML where span automatically gets closed and new span added to the HTML,
<p><span><span>plain text</span></span></p>
<div>test div</div>
<p></p>
I know, we can't have block element inside the inline element(i.e. HTML global rule), but I am not in position to make changes in the current system.
Update: I have tried to solution mention here but not worked well: https://stackoverflow.com/a/14603631/4420468
There is a config option to control this behavior.
valid_children
The valid_children enables you to control what child elements can exists within specified parent elements.
see docs for further information
In Sightly/AEM6, when including a parsys component, how can I set the text that says 'Drag Components Here' (cq:emptyText) to use a localised string? I have several parsys components as children of a custom component and need different text for each (e.g. Drag image components here, drag link components here).
Unfortunately it seems to be hard coded to use a specific I18n string, in /libs/cq/gui/components/authoring/clientlibs/editor/js/model/Inspectable.js
However, I was able to override the parsys control and change the CSS classes of the newpar from new section to cq-placeholder section and then include data-emptytext="Custom text" on the same html element.
in CQ5.6 we can do the following, maybe it works with AEM 6:
inherit your component from /libs/foundation/components/parsys
add a node which name is 'new' under your component node, which sling:resourceType is foundation/components/parsys/new or just copy the /libs/foundation/components/parsys/new
add cq:emptyText property to this node, which is the text appear in the box.
See the following code:
<div id="myTabContent" class="tab-content" data-sly-list="${properties.titles}">
<div data-sly-test.resourcePath1="${'{0}{1}' # format=['tab',itemList.index]}" class="${itemList.index != 0 && wcmmode.isPreview ? 'tab-pane fade' : 'tab-pane fade in active'}" id="${item}">
<div data-sly-resource="${ resourcePath1 # resourceType='wcm/foundation/components/parsys/newpar'}" class="cq-placeholder section" data-emptytext="${item}'s content"></div>
</div>
I have a form in a module that I want to appear in a modal window. Depending on the id the window may be blank, or if it does show any content all classes and ids are removed, so I can't validate or style the form.
Truncated Code:
...
<div id="feedback">
<div class="feedbackinner">
<!-- form module -->
<div id="contact-wrapper">
<!--form elements with ids and classes-->
</div>
<!-- end module -->
</div><!-- end .feedbackinner -->
</div><!-- end #feedback -->
This triggers the modal window without any ids or classes (using Firefox Web Developer outline current elements):
Click for ugly unstyled form that won't validate
This triggers a blank modal window:
Click if you like staring at a blank white box
So most importantly how do I keep all the ids and classes inside the modal window, and why won't calling the parent div work?
( As a work around I moved the form to a component view then called it using handler: 'iframe' instead of clone. I still want to know what's going on with the modal window. )
Thanks!
not seen the code but implications of using Element.clone on an element are apparent. By nature of HTML, id is meant to be unique. This means you are not really supposed to have more than one element with the same id injected into the DOM at the same time.
MooTools mirrors the sentiment correctly by implicitly removing the id from any element it creates a clone of:
https://github.com/mootools/mootools-core/blob/master/Source/Element/Element.js#L860
the .clone method accepts optional arguments which allow you to override stuff:
clone: function(contents, keepid){ - see http://mootools.net/docs/core/Element/Element#Element:clone as well.
cloned elements also lose all the events you may have assigned to them (but cloneEvents can help with that).
I would recommend looking at the squeezebox implementation and double check that the clone is implemented in the intended way. A better practice may be to adopt and re-attach the elements instead - or to copy the whole innerHTML (though this will once again cause non-delegated events to fail).