Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit 674aa15

Browse files
author
Gabriel Schulhof
committed
View source: Make HTML go through getSnippet()
1 parent 58c8940 commit 674aa15

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

demos/_assets/js/view-source.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,14 @@ function getSnippet( type, selector, source ) {
4848

4949
// First, try to grab a tag in this document
5050
if ( !$.mobile.path.isPath( selector ) ) {
51-
el = source.find( type + selector );
51+
el = source.find( ( "markup" === type ? "" : type ) + selector );
5252
// If this is not an embedded style, try a stylesheet reference
5353
if ( el.length === 0 && type === "style" ) {
5454
el = source.find( "link[rel='stylesheet']" + selector );
5555
}
56-
text = $( "<div></div>" ).append( el.contents().clone() ).html();
56+
text = $( "<div></div>" )
57+
.append( ( "markup" === type ? el : el.contents() ).clone() )
58+
.html();
5759
if ( !text ) {
5860
text = "";
5961
selector = el.attr( "href" ) || el.attr( "src" ) || "";
@@ -136,7 +138,7 @@ $.fn.viewSourceCode = function() {
136138
if ( self.attr( "data-demo-html" ) === "true" ) {
137139
data = self.html();
138140
} else {
139-
data = $( "<div></div>" ).append( $( self.attr( "data-demo-html" ) ).clone() ).html();
141+
data = getSnippet( "markup", self.attr( "data-demo-html" ), $( document ) );
140142
}
141143
sources.push( { title: "HTML", theme: "c", brush: "xml", data: fixData( data ) } );
142144
}

0 commit comments

Comments
 (0)