當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Parse5DomAdapter.makeCurrent方法代碼示例

本文整理匯總了TypeScript中@angular/platform-server/src/parse5_adapter.Parse5DomAdapter.makeCurrent方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Parse5DomAdapter.makeCurrent方法的具體用法?TypeScript Parse5DomAdapter.makeCurrent怎麽用?TypeScript Parse5DomAdapter.makeCurrent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在@angular/platform-server/src/parse5_adapter.Parse5DomAdapter的用法示例。


在下文中一共展示了Parse5DomAdapter.makeCurrent方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: isTag

import {OpaqueToken} from '@angular/core';
import {Parser, Serializer, TreeAdapters} from 'parse5';
import {Parse5DomAdapter} from '@angular/platform-server/src/parse5_adapter';
Parse5DomAdapter.makeCurrent(); // ensure Parse5DomAdapter is used
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
var DOM: any = getDOM();


const parser = new Parser(TreeAdapters.htmlparser2);
// TODO(gdi2290): fix encodeHtmlEntities: true
const serializer = new Serializer(TreeAdapters.htmlparser2, { encodeHtmlEntities: false });
const treeAdapter = parser.treeAdapter;

export function isTag(tagName, node): boolean {
  return node.type === 'tag' && node.name === tagName;
}

export function parseFragment(el: string): Object {
  return parser.parseFragment(el);
}

export function parseDocument(documentHtml: string): Object {
  if (!documentHtml) {
    throw new Error('parseDocument requires a document string');
  }
  if (typeof documentHtml !== 'string') {
    throw new Error('parseDocument needs to be a string to be parsed correctly');
  }

  const doc = parser.parse(documentHtml);
開發者ID:filipesilva,項目名稱:universal,代碼行數:30,代碼來源:document.ts

示例2:

// dom closure
import {Parse5DomAdapter} from '@angular/platform-server/src/parse5_adapter';
Parse5DomAdapter.makeCurrent();

export {provide, Inject, Optional, enableProdMode} from '@angular/core';

export * from './directives/index';


export * from './http/index';

export * from './pipes/index';

export * from './platform/index';

export * from './router/index';

export * from './env';

export * from './bootloader';
export * from './helper';
export * from './ng_preboot';
export * from './render';
export * from './stringify_element';
export * from 'angular2-express-engine';
export * from 'angular2-hapi-engine';
開發者ID:filipesilva,項目名稱:universal,代碼行數:26,代碼來源:node.ts

示例3: initNodeAdapter

export function initNodeAdapter() {
  Parse5DomAdapter.makeCurrent();
}
開發者ID:filipesilva,項目名稱:universal,代碼行數:3,代碼來源:node.ts


注:本文中的@angular/platform-server/src/parse5_adapter.Parse5DomAdapter.makeCurrent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。