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 }}
This repository was archived by the owner on May 29, 2019. It is now read-only.
Copy file name to clipboardExpand all lines: app/3.0/docs/devguide/style-shadow-dom.md
+102
Original file line number
Diff line number
Diff line change
@@ -492,6 +492,108 @@ index.html { .caption }
492
492
493
493
[See it on Plunker](http://plnkr.co/edit/hR3I4w?p=preview)
494
494
495
+
### Style undefined elements
496
+
497
+
To avoid FOUC (flash of unstyled content), you might want to style custom elements before they are
498
+
defined (that is, before the browser has attached their class definition to their markup tag). If
499
+
you don't, the browser may not apply any styles to the element at first paint. Typically, you'll
500
+
want to add styling for a few top-level elements so your application's layout displays while the
501
+
element definitions are being loaded.
502
+
503
+
There is a specification for a `:defined` pseudo-class selector to target elements that have been
504
+
defined, but the custom elements polyfill doesn't support this selector.
505
+
506
+
For a polyfill-friendly workaround, add an `unresolved` attribute to the element in markup. For
507
+
example:
508
+
509
+
```html
510
+
<my-elementunresolved></my-element>
511
+
```
512
+
513
+
Then style the unresolved element. For example:
514
+
515
+
```html
516
+
<style>
517
+
my-element[unresolved] {
518
+
height: 45px;
519
+
text-align: center;
520
+
...
521
+
}
522
+
</style>
523
+
```
524
+
525
+
Finally, remove the `unresolved` attribute in the element's `ready` callback:
526
+
527
+
```js
528
+
classMyElementextendsPolymerElement(){
529
+
...
530
+
ready(){
531
+
super.ready();
532
+
this.removeAttribute('unresolved');
533
+
...
534
+
}
535
+
...
536
+
}
537
+
```
538
+
539
+
### Style directional text with the :dir() selector
540
+
541
+
The `:dir()` CSS selector allows for styling text specific to its orientation
542
+
(right-to-left or left-to-right). See the [documentation on MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/:dir) for more information on the `:dir()`
543
+
selector.
544
+
545
+
The `DirMixin` provides limited support for the `:dir()` selector. Use of `:dir()` requires the
546
+
application to set the `dir` attribute on `<html>`. All elements will use the same direction.
547
+
548
+
Individual elements can opt-out of the global direction by setting the `dir` attribute
549
+
in HTML or in the `ready` callback, but the text direction of these elements must from then on be handled
550
+
manually.
551
+
552
+
Setting `dir` on an ancestor (other than `html`) has no effect.
553
+
554
+
For elements that extend `PolymerElement`, add `DirMixin` to use
555
+
`:dir()` styling.
556
+
557
+
Here's an example use of the `:dir()` selector:
558
+
559
+
`using-dir-selector.js` { .caption }
560
+
561
+
```js
562
+
import { PolymerElement, html } from'@polymer/polymer/polymer-element.js';
0 commit comments