Passed
Push — master ( 8f169b...36019d )
by Rafael
01:27
created

src/app/preview.js   A

Size

Lines of Code 27

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
nc 1
dl 0
loc 27
rs 10
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A preview.js ➔ ??? 0 5 2
1
const $ = jQuery;
2
3
export class Preview {
4
5
	constructor( options ) {
6
		this.options = options || {};
7
		this.options.context = this.options.context ? $( this.options.context ) : $( 'html' );
8
		this.$head = this.options.context.find( 'head' );
9
	}
10
11
	/**
12
	 * Append styles to the head.
13
	 *
14
	 * @since 1.0.0
15
	 */
16
	appendStyles( id, css ) {
17
		let $style = this.$head.find( '#' + id );
18
19
		if ( ! $style.length ) {
20
			$style = $( '<style>' );
21
			$style.attr( 'id', id );
22
			this.$head.append( $style );
23
		}
24
25
		$style.html( css );
26
	}
27
}
28