/// <summary> /// This will never return null, it will raise an exception if unable to satisfy the request /// </summary> public ITextFileLoader Get() { ITextFileLoader singleFileLoader = new LessCssKeyFrameScoper(_contentLoader); var sourceMappingMarkerIdGenerator = new SourceMappingMarkerIdGenerator(); if (_sourceMappingMarkerInjection == SourceMappingMarkerInjectionOptions.Inject) { singleFileLoader = new LessCssLineNumberingTextFileLoader( new LessCssCommentRemovingTextFileLoader(singleFileLoader), sourceMappingMarkerIdGenerator.MarkerGenerator, null // optionalSelectorMarkerInsertionCondition (null => insert markers for all selectors) ); } return(new DotLessCssCssLoader( new SameFolderImportFlatteningCssLoader( singleFileLoader, _sourceMappingMarkerInjection == SourceMappingMarkerInjectionOptions.Inject ? SameFolderImportFlatteningCssLoader.ContentLoaderCommentRemovalBehaviourOptions.CommentsAreAlreadyRemoved : SameFolderImportFlatteningCssLoader.ContentLoaderCommentRemovalBehaviourOptions.ContentIsUnprocessed, _errorBehaviour, _errorBehaviour, _logger ), () => sourceMappingMarkerIdGenerator.GetInsertedMarkerIds(), null, // optionalTagNameToRemove (null => no selectors need removing) _errorBehaviour, _logger )); }
public void NestedKeyFramesAndSelectorSpecifyingAnimation_KeyFramesComesAfterTargetSelector() { var content = "html { .toBeAnimated { animation: my-animation 2s; } @keyframes my-animation { } }"; var expected = "html { .toBeAnimated { animation: test1_my-animation 2s; } @keyframes test1_my-animation { } }"; var filename = "test1.css"; var contentLoader = new LessCssKeyFrameScoper( new FixedListCssContentLoader( new TextFileContents(filename, new DateTime(2017, 6, 17, 18, 24, 0), content) ) ); Assert.Equal( expected, contentLoader.Load(filename).Content ); }
public void NonNestedContent() { var content = "@keyframes my-animation { } .toBeAnimated { animation: my-animation 2s; }"; var expected = content; var filename = "test1.css"; var contentLoader = new LessCssKeyFrameScoper( new FixedListCssContentLoader( new TextFileContents(filename, new DateTime(2017, 6, 17, 18, 24, 0), content) ) ); Assert.Equal( expected, contentLoader.Load(filename).Content ); }
public void NestedKeyFramesAndSelectorSpecifyingMultipleAnimationName() { var content = "html { @keyframes my-animation { } @keyframes my-animation2 { } .toBeAnimated { animation-name: my-animation my-animation2; } }"; var expected = "html { @keyframes test1_my-animation { } @keyframes test1_my-animation2 { } .toBeAnimated { animation-name: test1_my-animation test1_my-animation2; } }"; var filename = "test1.css"; var contentLoader = new LessCssKeyFrameScoper( new FixedListCssContentLoader( new TextFileContents(filename, new DateTime(2017, 6, 17, 18, 24, 0), content) ) ); Assert.Equal( expected, contentLoader.Load(filename).Content ); }
public void NestedKeyFramesAndSelectorSpecifyingAnimation_FilenameUnsuitableForPrefix() { var content = "html { @keyframes my-animation { } .toBeAnimated { animation: my-animation 2s; } }"; var prefix = "scope" + "1".GetHashCode(); var expected = "html { @keyframes " + prefix + "_my-animation { } .toBeAnimated { animation: " + prefix + "_my-animation 2s; } }"; var filename = "1.css"; var contentLoader = new LessCssKeyFrameScoper( new FixedListCssContentLoader( new TextFileContents(filename, new DateTime(2017, 6, 17, 18, 24, 0), content) ) ); Assert.Equal( expected, contentLoader.Load(filename).Content ); }